53 lines
1.9 KiB
CMake
53 lines
1.9 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE_INIT "-Wall -Wextra -Wpedantic -Wno-language-extension-token -Wno-gnu-statement-expression-from-macro-expansion")
|
|
set(CMAKE_C_FLAGS_DEBUG_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -gdwarf-4")
|
|
|
|
project(Spider2 VERSION 1.0)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
find_package(CURL REQUIRED)
|
|
|
|
# Main executable
|
|
|
|
file(GLOB_RECURSE srcFiles src/*.c)
|
|
add_executable(${PROJECT_NAME} ${srcFiles})
|
|
target_link_libraries(${PROJECT_NAME} CURL::libcurl)
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
target_link_options(${PROJECT_NAME} PRIVATE -ltidy)
|
|
|
|
# Tests
|
|
|
|
include(CTest)
|
|
|
|
#file(GLOB_RECURSE testsToRun tests/*.c)
|
|
#list(FILTER srcFiles EXCLUDE REGEX main.c)
|
|
|
|
set(testsToRun tests/dynarr_extensions.c tests/dynarr_get.c tests/dynarr_get1_death.c tests/dynarr_get2_death.c tests/dynarr_get3_death.c tests/dynarr_insert.c tests/deque_push.c tests/deque_pop.c tests/json_write.c tests/hset_iter.c tests/hset_add.c)
|
|
|
|
create_test_sourcelist(tests CommonTests.c ${testsToRun})
|
|
add_executable(CommonTests ${tests} src/util.c src/json.c)
|
|
target_link_libraries(CommonTests CURL::libcurl)
|
|
target_include_directories(CommonTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
target_compile_options(CommonTests PRIVATE -gdwarf-4)
|
|
target_link_options(CommonTests PRIVATE -gdwarf-4)
|
|
#target_compile_options(CommonTests PRIVATE -gdwarf-4 -pg)
|
|
#target_link_options(CommonTests PRIVATE -gdwarf-4 -pg)
|
|
|
|
foreach(testFile IN LISTS testsToRun)
|
|
get_filename_component(testName ${testFile} NAME_WE)
|
|
add_test(NAME ${testName} COMMAND CommonTests tests/${testName})
|
|
string(REGEX MATCH "_death$" shouldDie ${testName})
|
|
if(shouldDie)
|
|
set_property(TEST ${testName} PROPERTY WILL_FAIL ON)
|
|
endif()
|
|
endforeach()
|
|
|
|
# Install rules
|
|
install(TARGETS Spider2)
|