allcing/CMakeLists.txt

56 lines
1.2 KiB
CMake

cmake_minimum_required(VERSION 3.27)
project(allcing C)
set(CMAKE_C_STANDARD 23)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# ---- thirdparty modules
include(CTest)
# ---- common config
add_library(allcing_config INTERFACE)
target_include_directories(allcing_config
INTERFACE
${PROJECT_SOURCE_DIR}
${NF7_GENERATED_DIR}
)
target_compile_options(allcing_config INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:
/W4
$<$<CONFIG:Debug>:/WX>
>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
-Wall -Wextra -Wpedantic
-Wno-gnu-zero-variadic-macro-arguments
$<$<CONFIG:Debug>:-Werror>
>
)
# ---- library header
add_library(allcing INTERFACE)
target_sources(allcing INTERFACE allcing.h)
target_include_directories(allcing SYSTEM INTERFACE .)
# ---- test binary
if (BUILD_TESTING)
add_executable(allcing_test)
target_sources(allcing_test PRIVATE test.c)
target_link_libraries(allcing_test PRIVATE allcing allcing_config)
add_test(NAME allcing_test COMMAND $<TARGET_FILE:allcing_test>)
endif()
# ---- example binary
add_executable(allcing_example EXCLUDE_FROM_ALL)
target_sources(allcing_example PRIVATE example.c)
target_link_libraries(allcing_example PRIVATE allcing allcing_config)
# ---- tool subdirs
add_subdirectory(tool EXCLUDE_FROM_ALL)