File tree Expand file tree Collapse file tree 1 file changed +15
-16
lines changed
Expand file tree Collapse file tree 1 file changed +15
-16
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.10)
22project (tec.h C)
3-
4- set (CMAKE_C_STANDARD 11)
3+ set (CMAKE_C_STANDARD 23)
54set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic" )
6-
75include_directories (include )
86
9- file (GLOB_RECURSE SRC_FILES "src/*.c" )
10-
11- file (GLOB_RECURSE TEST_SOURCES "tests/*.c" )
12-
13- list (FILTER SRC_FILES EXCLUDE REGEX ".*/main\\ .c$" )
14-
15- add_executable (main src/main.c ${SRC_FILES} )
16- add_executable (test_runner ${TEST_SOURCES} ${SRC_FILES} )
7+ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME )
8+ file (GLOB_RECURSE SRC_FILES "src/*.c" )
9+ file (GLOB_RECURSE TEST_SOURCES "tests/*.c" )
10+ list (FILTER SRC_FILES EXCLUDE REGEX ".*/main\\ .c$" )
1711
18- add_custom_target (test
19- COMMAND test_runner
20- DEPENDS test_runner
21- COMMENT "Running tests..."
22- )
12+ add_executable (main src/main.c ${SRC_FILES} )
13+ add_executable (test_runner ${TEST_SOURCES} ${SRC_FILES} )
14+ add_custom_target (build_tests
15+ COMMAND test_runner
16+ DEPENDS test_runner
17+ COMMENT "Running tests..."
18+ )
19+ else ()
20+ message (STATUS "tec.h: Header-only library (skipping executables)" )
21+ endif ()
You can’t perform that action at this time.
0 commit comments