[A] Add cmake option FORT_ENABLE_TESTING to turn on/off building tests and examples
This commit is contained in:
parent
74e2774ea3
commit
f8cf1331cd
@ -258,7 +258,7 @@ script:
|
|||||||
# Test package installation
|
# Test package installation
|
||||||
- cd ..
|
- cd ..
|
||||||
- rm -r build/*
|
- rm -r build/*
|
||||||
- cmake -H. -Bbuild -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX=`pwd`/install
|
- cmake -H. -Bbuild -DFORT_ENABLE_TESTING=OFF -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX=`pwd`/install
|
||||||
- cmake --build build --target all
|
- cmake --build build --target all
|
||||||
- cmake --build build -- install
|
- cmake --build build -- install
|
||||||
- ls `pwd`/install
|
- ls `pwd`/install
|
||||||
|
@ -15,6 +15,7 @@ include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
|
|||||||
option(FORT_ENABLE_ASTYLE "Enable astyle" OFF)
|
option(FORT_ENABLE_ASTYLE "Enable astyle" OFF)
|
||||||
option(FORT_ENABLE_WCHAR "Enable wchar support" ON)
|
option(FORT_ENABLE_WCHAR "Enable wchar support" ON)
|
||||||
option(FORT_ENABLE_UTF8 "Enable utf8 support" ON)
|
option(FORT_ENABLE_UTF8 "Enable utf8 support" ON)
|
||||||
|
option(FORT_ENABLE_TESTING "Enables building tests and examples" ON)
|
||||||
set(FORT_BUILD_TYPE "common" CACHE STRING "Build type")
|
set(FORT_BUILD_TYPE "common" CACHE STRING "Build type")
|
||||||
|
|
||||||
set_property(CACHE FORT_BUILD_TYPE PROPERTY STRINGS
|
set_property(CACHE FORT_BUILD_TYPE PROPERTY STRINGS
|
||||||
@ -155,9 +156,11 @@ set(FORT_HAVE_UTF8 "${FORT_ENABLE_UTF8}" CACHE STRING "fort option")
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
|
if(FORT_ENABLE_TESTING)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -176,10 +179,11 @@ add_custom_target(headers SOURCES ${FortHeaders})
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Set preprocessor macros for all test builds.
|
# Set preprocessor macros for all test builds.
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
if(FORT_ENABLE_TESTING)
|
||||||
target_compile_definitions(${PROJECT_NAME}_test_dev PRIVATE FT_TEST_BUILD=1)
|
target_compile_definitions(${PROJECT_NAME}_test_dev PRIVATE FT_TEST_BUILD=1)
|
||||||
target_compile_definitions(${PROJECT_NAME}_test_cpp PRIVATE FT_TEST_BUILD=1)
|
target_compile_definitions(${PROJECT_NAME}_test_cpp PRIVATE FT_TEST_BUILD=1)
|
||||||
target_compile_definitions(${PROJECT_NAME}_test PRIVATE FT_TEST_BUILD=1)
|
target_compile_definitions(${PROJECT_NAME}_test PRIVATE FT_TEST_BUILD=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Setup text formatting via astyle.
|
# Setup text formatting via astyle.
|
||||||
@ -252,7 +256,7 @@ endif()
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Add examples and unit tests to ctest driver.
|
# Add examples and unit tests to ctest driver.
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
if(FORT_ENABLE_TESTING)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
list(APPEND ${PROJECT_NAME}_ctests
|
list(APPEND ${PROJECT_NAME}_ctests
|
||||||
${${PROJECT_NAME}_tests}
|
${${PROJECT_NAME}_tests}
|
||||||
@ -260,6 +264,7 @@ list(APPEND ${PROJECT_NAME}_ctests
|
|||||||
foreach(exe ${${PROJECT_NAME}_ctests})
|
foreach(exe ${${PROJECT_NAME}_ctests})
|
||||||
add_test(NAME ${exe} COMMAND ${exe})
|
add_test(NAME ${exe} COMMAND ${exe})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Exported targets for outer applications.
|
# Exported targets for outer applications.
|
||||||
|
Loading…
Reference in New Issue
Block a user