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
|
2021-01-06 07:10:59 +00:00
|
|
|
project (crow_all LANGUAGES CXX)
|
2016-11-19 10:18:21 +00:00
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
# Define the module path
|
2021-02-09 11:46:25 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
2016-10-03 11:47:22 +00:00
|
|
|
|
2021-01-06 07:10:59 +00:00
|
|
|
# Set required C++ Standard
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
2021-01-08 15:13:39 +00:00
|
|
|
|
2014-08-06 23:31:27 +00:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
2016-10-03 11:47:22 +00:00
|
|
|
message(STATUS "No build type selected, default to Release")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
2014-08-06 23:31:27 +00:00
|
|
|
endif()
|
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
#####################################
|
|
|
|
# Define Options
|
|
|
|
#####################################
|
2021-01-11 06:04:46 +00:00
|
|
|
option(BUILD_EXAMPLES "Builds the examples in the project" ON)
|
|
|
|
option(BUILD_TESTING "Builds the tests in the project" ON)
|
2021-01-08 15:13:39 +00:00
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Define CMake Module Imports
|
|
|
|
#####################################
|
2021-02-09 11:46:25 +00:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies.cmake)
|
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler_options.cmake)
|
2021-01-08 15:13:39 +00:00
|
|
|
|
|
|
|
#####################################
|
|
|
|
# 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
|
2021-02-09 11:46:25 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
2021-01-08 15:13:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
include_directories("${PROJECT_INCLUDE_DIR}")
|
2021-02-09 11:46:25 +00:00
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
2021-01-08 15:13:39 +00:00
|
|
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}") # To include crow_all.h
|
2015-02-20 20:46:28 +00:00
|
|
|
endif()
|
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
#####################################
|
|
|
|
# Define Targets
|
|
|
|
#####################################
|
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
|
2021-04-01 05:59:40 +00:00
|
|
|
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/merge_all.py
|
2021-02-09 11:46:25 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
2021-01-08 15:13:39 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2021-02-09 11:46:25 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/*.h ${CMAKE_CURRENT_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)
|
2016-11-22 16:50:06 +00:00
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
# Examples
|
2021-01-06 07:10:59 +00:00
|
|
|
if(BUILD_EXAMPLES)
|
2021-01-08 15:13:39 +00:00
|
|
|
add_subdirectory(examples)
|
2021-01-06 07:10:59 +00:00
|
|
|
endif()
|
2016-10-03 11:47:22 +00:00
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
# Tests
|
2021-01-06 07:10:59 +00:00
|
|
|
if (NOT MSVC AND BUILD_TESTING)
|
2016-10-03 11:47:22 +00:00
|
|
|
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)
|
2021-01-06 07:10:59 +00:00
|
|
|
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)
|
2021-07-03 20:02:32 +00:00
|
|
|
|
|
|
|
set(CPACK_GENERATOR "DEB")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CrowCpp")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
|
|
|
|
|
|
|
include(CPack)
|