71 lines
2.3 KiB
CMake
71 lines
2.3 KiB
CMake
cmake_minimum_required(VERSION 3.21)
|
|
set(version 1.0)
|
|
project(VWeb VERSION ${version})
|
|
set(project_lower vweb)
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUGSOFT")
|
|
option(BUILD_TESTS "Build tests" OFF)
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
find_package(Threads REQUIRED)
|
|
|
|
include(CMakeMacros.txt)
|
|
|
|
add_subdirectory(Source)
|
|
add_subdirectory(Includes)
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/)
|
|
get_property(source_files GLOBAL PROPERTY SRCS)
|
|
set(SOURCE_FILES ${source_files})
|
|
add_library(VWeb ${SOURCE_FILES})
|
|
|
|
include(GNUInstallDirs)
|
|
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
|
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
|
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
|
|
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
|
|
|
|
get_property(header_files GLOBAL PROPERTY Headers)
|
|
|
|
install(FILES ${header_files} DESTINATION include/VWeb-${version})
|
|
install(TARGETS ${PROJECT_NAME}
|
|
EXPORT ${PROJECT_NAME}-targets
|
|
LIBRARY DESTINATION lib/$<CONFIG>
|
|
ARCHIVE DESTINATION lib/$<CONFIG>
|
|
)
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
DESTINATION lib/${PROJECT_NAME}-${version})
|
|
|
|
configure_file(
|
|
${PROJECT_SOURCE_DIR}/pkg/${project_lower}-config.cmake.in
|
|
${PROJECT_BINARY_DIR}/pkg/${project_lower}-config.cmake @ONLY)
|
|
|
|
configure_file(
|
|
${PROJECT_SOURCE_DIR}/${project_lower}-config-version.cmake.in
|
|
${PROJECT_BINARY_DIR}/${project_lower}-config-version.cmake @ONLY)
|
|
|
|
install(FILES ${PROJECT_BINARY_DIR}/pkg/${project_lower}-config.cmake
|
|
${PROJECT_BINARY_DIR}/${project_lower}-config-version.cmake
|
|
DESTINATION lib/${PROJECT_NAME}-${version})
|
|
|
|
if (BUILD_TESTS)
|
|
add_subdirectory(Tests)
|
|
get_property(test_sources GLOBAL PROPERTY Test_SRCS)
|
|
set(TESTS_SRCS ${test_sources})
|
|
|
|
Include(FetchContent)
|
|
FetchContent_Declare(
|
|
Catch2
|
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
|
GIT_TAG v3.4.0
|
|
)
|
|
FetchContent_MakeAvailable(Catch2)
|
|
add_executable(tests ${SOURCE_FILES} ${TESTS_SRCS})
|
|
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
|
|
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
|
include(CTest)
|
|
include(Catch)
|
|
catch_discover_tests(tests WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Tests)
|
|
endif () |