core-legacy/CMakeLists.txt

85 lines
2.5 KiB
Text
Raw Normal View History

2019-07-12 19:05:56 +00:00
cmake_minimum_required (VERSION 3.2)
2019-09-01 17:34:50 +00:00
project(core)
2019-07-12 19:05:56 +00:00
2019-09-01 17:34:50 +00:00
include(CheckIncludeFileCXX)
2019-07-12 19:05:56 +00:00
2019-09-01 17:34:50 +00:00
check_include_file_cxx(any HAS_ANY)
check_include_file_cxx(string_view HAS_STRING_VIEW)
if(HAS_ANY AND HAS_STRING_VIEW)
set(CMAKE_CXX_STANDARD 17)
2019-07-12 19:05:56 +00:00
else()
2019-09-01 17:34:50 +00:00
set(CMAKE_CXX_STANDARD 14)
2019-07-12 19:05:56 +00:00
endif()
2019-09-01 17:34:50 +00:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
2019-09-08 17:54:38 +00:00
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")
2019-09-01 17:34:50 +00:00
##########
# If you include the drogon source code locally in your project, use this method to add drogon
# add_subdirectory(drogon)
# set(Drogon_DIR ${PROJECT_BINARY_DIR}/drogon)
# find_package(Drogon CONFIG REQUIRED NO_DEFAULT_PATH)
# include_directories(${DROGON_INCLUDE_DIRS})
# link_libraries(${DROGON_LIBRARIES})
##########
2019-09-08 12:28:50 +00:00
# find_package(Drogon CONFIG REQUIRED)
# include_directories(${DROGON_INCLUDE_DIRS})
# link_libraries(${DROGON_LIBRARIES})
2019-09-01 17:34:50 +00:00
if(CMAKE_CXX_STANDARD LESS 17)
#With C++14, use boost to support any and string_view
message(STATUS "use c++14")
find_package(Boost 1.61.0 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
else()
message(STATUS "use c++17")
2019-07-12 19:05:56 +00:00
endif()
2019-09-01 17:34:50 +00:00
aux_source_directory(./ SRC_DIR)
aux_source_directory(controllers CTL_SRC)
aux_source_directory(filters FILTER_SRC)
aux_source_directory(plugins PLUGIN_SRC)
aux_source_directory(models MODEL_SRC)
aux_source_directory(helpers HELPER_SRC)
file(GLOB SCP_LIST ${CMAKE_CURRENT_SOURCE_DIR}/views/*.csp)
foreach(cspFile ${SCP_LIST})
message(STATUS "cspFile:" ${cspFile})
EXEC_PROGRAM(basename ARGS "${cspFile} .csp" OUTPUT_VARIABLE classname)
message(STATUS "view classname:" ${classname})
ADD_CUSTOM_COMMAND(OUTPUT ${classname}.h ${classname}.cc
COMMAND drogon_ctl
ARGS create view ${cspFile}
DEPENDS ${cspFile}
VERBATIM )
set(VIEWSRC ${VIEWSRC} ${classname}.cc)
endforeach()
2019-07-12 19:05:56 +00:00
2019-09-22 11:36:01 +00:00
configure_file("config.json" "config.json" COPYONLY)
2019-07-12 19:05:56 +00:00
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
2019-09-01 17:34:50 +00:00
add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC})
2019-08-06 22:01:01 +00:00
2019-09-08 12:28:50 +00:00
add_subdirectory(drogon)
target_link_libraries(${PROJECT_NAME} PRIVATE drogon)
2020-02-23 00:12:39 +00:00
add_custom_target(migrations
COMMAND ./compile_migrations.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
2020-02-23 00:12:39 +00:00
add_custom_target(run
COMMAND core
DEPENDS core
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
)
add_custom_target(test
2020-02-23 21:54:33 +00:00
COMMAND ./run_tests.sh ${CMAKE_BINARY_DIR}/core ${CMAKE_SOURCE_DIR}/config.testing.json
DEPENDS core
2020-02-23 21:54:33 +00:00
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tavern_tests
)