2018-10-15 14:46:53 +00:00
|
|
|
cmake_minimum_required(VERSION 3.2)
|
|
|
|
Project({{ProjectName}})
|
2018-10-21 06:52:41 +00:00
|
|
|
|
|
|
|
link_directories(/usr/local/lib)
|
|
|
|
link_libraries(drogon trantor pthread dl)
|
2018-10-15 14:46:53 +00:00
|
|
|
|
|
|
|
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})
|
2018-10-17 06:00:23 +00:00
|
|
|
if(version LESS 5.4.0)
|
2018-10-15 14:46:53 +00:00
|
|
|
MESSAGE(STATUS "gcc is too old")
|
|
|
|
stop()
|
|
|
|
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()
|
2018-10-17 06:00:23 +00:00
|
|
|
set(CMAKE_CXX_STD_FLAGS c++17)
|
2018-10-15 14:46:53 +00:00
|
|
|
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/)
|
2018-10-21 06:52:41 +00:00
|
|
|
|
2018-10-15 14:46:53 +00:00
|
|
|
#jsoncpp
|
|
|
|
find_package (Jsoncpp REQUIRED)
|
|
|
|
include_directories(${JSONCPP_INCLUDE_DIRS})
|
2018-10-21 06:52:41 +00:00
|
|
|
link_libraries(${JSONCPP_LIBRARIES})
|
|
|
|
|
|
|
|
#uuid
|
|
|
|
find_package (UUID REQUIRED)
|
|
|
|
include_directories(${UUID_INCLUDE_DIR})
|
|
|
|
link_libraries(${UUID_LIBRARIES})
|
|
|
|
|
|
|
|
#OpenSSL
|
|
|
|
find_package (OpenSSL)
|
|
|
|
if(OpenSSL_FOUND)
|
|
|
|
link_libraries(${OPENSSL_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#zlib
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIR})
|
|
|
|
link_libraries(${ZLIB_LIBRARIES})
|
2018-10-15 14:46:53 +00:00
|
|
|
|
|
|
|
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})
|
2018-10-17 10:43:51 +00:00
|
|
|
EXEC_PROGRAM(basename ARGS "${cspFile} .csp" OUTPUT_VARIABLE classname)
|
2018-10-15 14:46:53 +00:00
|
|
|
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})
|