Crow/CMakeLists.txt

81 lines
2.6 KiB
CMake
Raw Normal View History

2021-01-08 15:13:39 +00:00
#####################################
# Define Project-Wide Settings
#####################################
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
# Define the Project Name and Description
project (crow_all LANGUAGES CXX)
2021-01-08 15:13:39 +00:00
# Define the module path
2014-08-14 23:22:02 +00:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# Set required C++ Standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
2021-01-08 15:13:39 +00:00
# Generate the compile_commands.json file
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
2021-01-08 15:13:39 +00:00
#####################################
# Define Options
#####################################
option(BUILD_EXAMPLES "Builds the examples in the project" OFF)
option(BUILD_TESTING "Builds the tests in the project" OFF)
#####################################
# Define CMake Module Imports
#####################################
include(${CMAKE_SOURCE_DIR}/cmake/compiler_options.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/dependencies.cmake)
#####################################
# Define project-wide imports
#####################################
# this can be alternatively (and as recommended way) done with target_include_directories()
if(BUILD_EXAMPLES OR BUILD_TESTING)
set(PROJECT_INCLUDE_DIR
${PROJECT_SOURCE_DIR}/include
)
include_directories("${PROJECT_INCLUDE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}") # To include crow_all.h
endif()
2021-01-08 15:13:39 +00:00
#####################################
# Define Targets
#####################################
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
COMMAND python ${PROJECT_SOURCE_DIR}/scripts/merge_all.py
${PROJECT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${PROJECT_SOURCE_DIR}/include/*.h ${PROJECT_SOURCE_DIR}/include/crow/*.h ${PROJECT_SOURCE_DIR}/include/crow/middlewares/*.h
2014-08-06 16:18:33 +00:00
)
2021-01-08 15:13:39 +00:00
# Amalgamation
add_custom_target(amalgamation ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h)
2021-01-08 15:13:39 +00:00
# Examples
if(BUILD_EXAMPLES)
2021-01-08 15:13:39 +00:00
add_subdirectory(examples)
endif()
2021-01-08 15:13:39 +00:00
# Tests
if (NOT MSVC AND BUILD_TESTING)
add_subdirectory(tests)
enable_testing()
add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest)
add_test(NAME template_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/template/test.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/template)
endif()
2014-08-07 16:14:27 +00:00
2021-01-08 15:13:39 +00:00
#####################################
# Install Files
#####################################
2020-12-05 07:21:00 +00:00
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h DESTINATION include)