Raw
1 include(CheckFunctionExists)
2
3 cmake_minimum_required(VERSION 3.16..3.29)
4
5 project(clar LANGUAGES C)
6
7 option(BUILD_EXAMPLE "Build the example." ON)
8
9 check_function_exists(realpath CLAR_HAS_REALPATH)
10 if(CLAR_HAS_REALPATH)
11 add_compile_definitions(-DCLAR_HAS_REALPATH)
12 endif()
13
14 add_library(clar INTERFACE)
15 target_sources(clar INTERFACE
16 clar.c
17 clar.h
18 clar/fixtures.h
19 clar/fs.h
20 clar/print.h
21 clar/sandbox.h
22 clar/summary.h
23 )
24 set_target_properties(clar PROPERTIES
25 C_STANDARD 90
26 C_STANDARD_REQUIRED ON
27 C_EXTENSIONS OFF
28 )
29
30 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
31 include(CTest)
32 if(BUILD_TESTING)
33 add_subdirectory(test)
34 endif()
35
36 if(BUILD_EXAMPLE)
37 add_subdirectory(example)
38 endif()
39 endif()