Files
IACore/CMakeLists.txt
2025-11-29 09:45:08 +05:30

73 lines
2.6 KiB
CMake

cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
project(IACore)
enable_language(C)
# Default to ON if root, OFF if dependency
option(IACore_BUILD_TESTS "Build unit tests" ${PROJECT_IS_TOP_LEVEL})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Configuring IACore for Debug..")
add_compile_options(-O0 -g)
add_compile_definitions("__IA_DEBUG=1")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Configuring IACore for Release..")
add_compile_options(-O3 -g0)
add_compile_definitions("__IA_DEBUG=0")
else()
message(FATAL_ERROR "Unknown CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\"")
endif()
message(STATUS "Detected Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
# Check if the compiler is MSVC (cl.exe), but allow Clang acting like MSVC (clang-cl)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Note: clang-cl usually reports itself as "Clang" in newer CMake versions,
# but if it reports MSVC with a Clang simulation, we want to allow it.
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR
"\n\n"
"-------------------------------------------------------------\n"
"CRITICAL ERROR: Unsupported Compiler Detected (MSVC/cl.exe)\n"
"-------------------------------------------------------------\n"
"IACore requires GCC or Clang to compile.\n"
"For compiling with IACore on Windows, please use Clang Tools for MSVC.\n"
"-------------------------------------------------------------\n"
)
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(
-Wall -Wextra -Wpedantic
# Suppress warning for the statement expression macro if -pedantic is on
-Wno-language-extension-token
)
endif()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_subdirectory(Vendor/)
add_subdirectory(Src/)
if(IACore_BUILD_TESTS)
add_subdirectory(Tests)
endif()
# ------------------------------------------------------------
# Local Development Sandboxes (not included in source control)
# ------------------------------------------------------------
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.local")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/.local")
endif()