60 lines
1.9 KiB
Plaintext
60 lines
1.9 KiB
Plaintext
|
cmake_minimum_required(VERSION 3.2)
|
||
|
Project({{ProjectName}})
|
||
|
link_libraries(drogon trantor uuid pthread jsoncpp dl z)
|
||
|
find_package (OpenSSL)
|
||
|
if(OpenSSL_FOUND)
|
||
|
link_libraries(ssl crypto)
|
||
|
endif()
|
||
|
|
||
|
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||
|
EXEC_PROGRAM (gcc ARGS "--version | grep '^gcc'|awk '{print $3}' | sed s'/)//g' | sed s'/-.*//g'" OUTPUT_VARIABLE version)
|
||
|
MESSAGE(STATUS "This is gcc version:: " ${version})
|
||
|
if(version LESS 4.9.0)
|
||
|
MESSAGE(STATUS "gcc is too old")
|
||
|
stop()
|
||
|
elseif (version LESS 6.1.0)
|
||
|
MESSAGE(STATUS "c++11")
|
||
|
set(CMAKE_CXX_STD_FLAGS c++11)
|
||
|
elseif(version LESS 7.1.0)
|
||
|
set(CMAKE_CXX_STD_FLAGS c++14)
|
||
|
MESSAGE(STATUS "c++14")
|
||
|
else()
|
||
|
set(CMAKE_CXX_STD_FLAGS c++17)
|
||
|
set(DR_DEFS "USE_STD_ANY")
|
||
|
MESSAGE(STATUS "c++17")
|
||
|
endif()
|
||
|
else()
|
||
|
set(CMAKE_CXX_STD_FLAGS c++11)
|
||
|
endif()
|
||
|
|
||
|
if(CMAKE_BUILD_TYPE STREQUAL "")
|
||
|
set(CMAKE_BUILD_TYPE Release)
|
||
|
endif()
|
||
|
|
||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -std=${CMAKE_CXX_STD_FLAGS}")
|
||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -std=${CMAKE_CXX_STD_FLAGS}")
|
||
|
|
||
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules/)
|
||
|
#jsoncpp
|
||
|
find_package (Jsoncpp REQUIRED)
|
||
|
include_directories(${JSONCPP_INCLUDE_DIRS})
|
||
|
|
||
|
AUX_SOURCE_DIRECTORY(./ SRC_DIR)
|
||
|
AUX_SOURCE_DIRECTORY(controllers CTL_SRC)
|
||
|
AUX_SOURCE_DIRECTORY(filters FILTER_SRC)
|
||
|
|
||
|
FILE(GLOB SCP_LIST ${CMAKE_CURRENT_SOURCE_DIR}/views/*.csp)
|
||
|
foreach(cspFile ${SCP_LIST})
|
||
|
message(STATUS "cspFile:" ${cspFile})
|
||
|
EXEC_PROGRAM(basename ARGS "-s .csp ${cspFile}" 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()
|
||
|
|
||
|
add_executable({{ProjectName}} ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC})
|