File tree Expand file tree Collapse file tree 3 files changed +9
-12
lines changed
Expand file tree Collapse file tree 3 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.25)
22
33project (tinyclib VERSION 0.1.2 LANGUAGES C )
44
5- # Settings
5+ # Settings and options
6+ option (TL_BUILD_TESTS "Build tinyclib tests" ON )
67set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
78set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib)
89set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib)
@@ -78,7 +79,7 @@ add_library(tinyclib::tinyclib ALIAS tinyclib)
7879set_target_properties (tinyclib PROPERTIES POSITION_INDEPENDENT_CODE ON )
7980
8081# Build tests
81- if (BUILD_TESTS )
82+ if (TL_BUILD_TESTS )
8283 include (CTest )
8384 include (FetchContent )
8485 set (TEST_TARGETS
@@ -96,12 +97,6 @@ if(BUILD_TESTS)
9697 GIT_TAG v2.6.1
9798 )
9899 FetchContent_MakeAvailable (Unity)
99- FetchContent_GetProperties (Unity)
100-
101- if (NOT TARGET Unity)
102- add_library (Unity STATIC ${unity_SOURCE_DIR} /src/unity.c )
103- endif ()
104- target_include_directories (Unity PUBLIC ${unity_SOURCE_DIR} /src )
105100
106101 enable_testing ()
107102 foreach (t IN LISTS TEST_TARGETS)
Original file line number Diff line number Diff line change 1212 "cacheVariables" : {
1313 "CMAKE_BUILD_TYPE" : " Debug" ,
1414 "CMAKE_EXPORT_COMPILE_COMMANDS" : " ON" ,
15- "BUILD_TESTS " : " ON"
15+ "TL_BUILD_TESTS " : " ON"
1616 }
1717 }
1818 ],
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ TEST_FILES := tests/unit/*.c
1111EXAMPLE_FILES := $(wildcard examples/* /* .c)
1212ALL_FILES := $(SRC_FILES ) $(TEST_FILES ) $(EXAMPLE_FILES )
1313
14+ PRESET ?= default
15+
1416.PHONY : help install build clean clean-bin test format lint check check-all fix
1517
1618help : # # Show available make targets
@@ -20,11 +22,11 @@ help: ## Show available make targets
2022 @awk ' BEGIN {FS = ":.*## "} /^[a-zA-Z_-]+:.*## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST )
2123
2224configure : # # Configure cmake
23- cmake --preset default
25+ cmake --preset $( PRESET )
2426
2527build : # # Build the project
26- @test -d " $( BUILD_DIR) " || cmake --preset default
27- cmake --build --preset default
28+ @test -d " $( BUILD_DIR) " || cmake --preset $( PRESET )
29+ cmake --build --preset $( PRESET )
2830
2931clean : # # Remove build directory
3032 @test -n " $( CURDIR) " && [ " $( CURDIR) " != " /" ]
You can’t perform that action at this time.
0 commit comments