libtree/CMakeLists.txt

80 lines
1.6 KiB
CMake

cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
project (libtree++ VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
#
# Set the required C++ standard
#
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#
# We want to have a compile_commands.json file
#
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
#
# Module includes for compdb and doxygen
#
include(compdb)
include(doxygen)
configure_file(${PROJECT_SOURCE_DIR}/src/config.hpp.in ${PROJECT_SOURCE_DIR}/src/config.hpp @ONLY)
set(generated "${PROJECT_SOURCE_DIR}/src/config.hpp")
add_custom_target(clean-generated COMMAND rm -f ${generated})
add_library(tree STATIC
src/config.hpp
include/Tree/tree.hpp
src/Tree/tree.cpp
)
target_include_directories(tree PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE src
)
#
# Everything TEST related
#
option(TEST_TREE "Turn running of tree specific tests on/off" ON)
IF(${TEST_TREE})
enable_testing()
message(STATUS "Tree tests enabled")
include(CTest)
ELSE()
message(STATUS "Tree tests disabled")
ENDIF()
IF (${TEST_TREE})
add_my_test(TEST test_base
SOURCES tests/test_base.cpp
LIBS tree
)
add_my_test(TEST test_add_child
SOURCES tests/test_add_child.cpp
LIBS tree
)
get_property(_mytests GLOBAL PROPERTY _mytests)
FOREACH( _test ${_mytests})
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
target_compile_options(${_test} PUBLIC -Wall -g -O0)
ELSE()
target_compile_options(${_test} PUBLIC -O4)
ENDIF()
ENDFOREACH()
ENDIF()