2019-07-12 19:05:56 +00:00
|
|
|
cmake_minimum_required (VERSION 3.2)
|
2019-07-29 10:10:45 +00:00
|
|
|
Project(core)
|
2019-07-12 19:05:56 +00:00
|
|
|
|
|
|
|
link_directories(/usr/local/lib)
|
|
|
|
link_libraries(drogon trantor pthread dl)
|
|
|
|
|
|
|
|
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 5.4.0)
|
|
|
|
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)
|
|
|
|
MESSAGE(STATUS "c++17")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_STD_FLAGS c++17)
|
|
|
|
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 ${PROJECT_SOURCE_DIR}/cmake_modules/)
|
|
|
|
|
|
|
|
#jsoncpp
|
|
|
|
find_package (Jsoncpp REQUIRED)
|
|
|
|
include_directories(${JSONCPP_INCLUDE_DIRS})
|
|
|
|
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)
|
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
|
|
link_libraries(${OPENSSL_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#zlib
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIR})
|
|
|
|
link_libraries(${ZLIB_LIBRARIES})
|
|
|
|
|
|
|
|
#find postgres
|
|
|
|
find_package(PostgreSQL)
|
|
|
|
if(PostgreSQL_FOUND)
|
|
|
|
include_directories(${PostgreSQL_INCLUDE_DIR})
|
|
|
|
link_libraries(${PostgreSQL_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#Find mysql, only mariadb client liberary is supported
|
|
|
|
find_package(MySQL)
|
|
|
|
if(MYSQL_FOUND)
|
|
|
|
message(STATUS "inc:" ${MYSQL_INCLUDE_DIR})
|
|
|
|
message(STATUS "libs:" ${MYSQL_CLIENT_LIBS})
|
|
|
|
message(STATUS "version:" ${MYSQL_VERSION_STRING})
|
|
|
|
if(MYSQL_VERSION_STRING STREQUAL "")
|
|
|
|
message(STATUS "The mysql in your system is not the mariadb, so we can't use it in drogon")
|
|
|
|
else()
|
|
|
|
message(STATUS "Ok! We find the mariadb!")
|
|
|
|
include_directories(${MYSQL_INCLUDE_DIR})
|
|
|
|
link_libraries(${MYSQL_CLIENT_LIBS})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#Find sqlite3.
|
|
|
|
find_package (SQLite3)
|
|
|
|
if (SQLITE3_FOUND)
|
|
|
|
include_directories(${SQLITE3_INCLUDE_DIRS})
|
|
|
|
link_libraries(${SQLITE3_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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)
|
2019-07-14 22:39:37 +00:00
|
|
|
AUX_SOURCE_DIRECTORY(helpers HELPER_SRC)
|
2019-07-12 19:05:56 +00:00
|
|
|
|
|
|
|
include_directories(/usr/local/include)
|
|
|
|
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
2019-08-06 21:30:03 +00:00
|
|
|
add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC})
|