mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
CMake: Added test configuration
This commit is contained in:
@@ -8,6 +8,7 @@ set(CGLM_BUILD)
|
|||||||
option(CGLM_STATIC "Static build" ON)
|
option(CGLM_STATIC "Static build" ON)
|
||||||
option(CGLM_SHARED "Shared build" OFF)
|
option(CGLM_SHARED "Shared build" OFF)
|
||||||
option(CGLM_USE_C11 "" OFF)
|
option(CGLM_USE_C11 "" OFF)
|
||||||
|
option(CGLM_USE_TEST "Enable Tests" OFF)
|
||||||
|
|
||||||
if(CGLM_STATIC AND NOT CGLM_SHARED)
|
if(CGLM_STATIC AND NOT CGLM_SHARED)
|
||||||
set(CGLM_BUILD STATIC)
|
set(CGLM_BUILD STATIC)
|
||||||
@@ -16,7 +17,7 @@ else(CGLM_SHARED)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CGLM_USE_C11)
|
if(CGLM_USE_C11)
|
||||||
set(C_STANDARD 99)
|
set(C_STANDARD 11)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
@@ -141,8 +142,7 @@ add_library(cglm
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(cglm PUBLIC
|
target_include_directories(cglm PUBLIC
|
||||||
${CMAKE_CURRENT_LIST_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_PREFIX}>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(LDFLAGS)
|
if(LDFLAGS)
|
||||||
@@ -166,3 +166,9 @@ if(CGLM_SHARED)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/cglm COMPONENT development)
|
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/cglm COMPONENT development)
|
||||||
|
|
||||||
|
# Test Configuration
|
||||||
|
if(CGLM_USE_TEST)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
|||||||
41
test/CMakeLists.txt
Normal file
41
test/CMakeLists.txt
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8.2)
|
||||||
|
|
||||||
|
# List all files containing tests. (Change as needed)
|
||||||
|
set(TESTFILES
|
||||||
|
runner.c
|
||||||
|
src/test_euler.c
|
||||||
|
src/test_bezier.c
|
||||||
|
src/test_cam.c
|
||||||
|
src/test_struct.c
|
||||||
|
src/test_clamp.c
|
||||||
|
src/test_common.c
|
||||||
|
src/tests.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(TEST_MAIN tests)
|
||||||
|
set(TEST_RUNNER_PARAMS "")
|
||||||
|
|
||||||
|
add_executable(${TEST_MAIN} ${TESTFILES})
|
||||||
|
|
||||||
|
target_link_libraries(${TEST_MAIN} PRIVATE cglm m)
|
||||||
|
target_include_directories(${TEST_MAIN} PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/include
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/src
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(${TEST_MAIN} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||||
|
|
||||||
|
if(LDFLAGS)
|
||||||
|
target_compile_options(${TEST_MAIN} PRIVATE ${LDFLAGS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# set(C_STANDARD 99)
|
||||||
|
# set(C_STANDARD_REQUIRED YES)
|
||||||
|
|
||||||
|
# if(CGLM_USE_C11)
|
||||||
|
# set(C_STANDARD 11)
|
||||||
|
# endif()
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME cglm.${TEST_MAIN}
|
||||||
|
COMMAND ${TEST_MAIN} ${TEST_RUNNER_PARAMS})
|
||||||
Reference in New Issue
Block a user