cmake_minimum_required (VERSION 3.2) Project(core) 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) message(STATUS "libpq inc path:" ${PostgreSQL_INCLUDE_DIR}) message(STATUS "libpq lib:" ${PostgreSQL_LIBRARIES}) include_directories(${PostgreSQL_INCLUDE_DIR}) link_libraries(${PostgreSQL_LIBRARIES}) set(DROGON_SOURCES ${DROGON_SOURCES} orm_lib/src/postgresql_impl/PostgreSQLResultImpl.cc) if(LIBPQ_BATCH_MODE) try_compile(libpq_supports_batch ${CMAKE_BINARY_DIR}/cmaketest ${PROJECT_SOURCE_DIR}/cmake/tests/test_libpq_batch_mode.cc LINK_LIBRARIES ${PostgreSQL_LIBRARIES} CMAKE_FLAGS "-Dinclude_directories=${PostgreSQL_INCLUDE_DIR}") endif() if(libpq_supports_batch) message(STATUS "The libpq supports fatch mode") OPTION(LIBPQ_SUPPORTS_BATCH_MODE "ibpq fatch mode" ON) set(DROGON_SOURCES ${DROGON_SOURCES} orm_lib/src/postgresql_impl/PgBatchConnection.cc) else() OPTION(LIBPQ_SUPPORTS_BATCH_MODE "ibpq fatch mode" OFF) set(DROGON_SOURCES ${DROGON_SOURCES} orm_lib/src/postgresql_impl/PgConnection.cc) endif() 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 "") set(MYSQL_FOUND false) 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}) set(DROGON_SOURCES ${DROGON_SOURCES} orm_lib/src/mysql_impl/MysqlConnection.cc orm_lib/src/mysql_impl/MysqlResultImpl.cc) 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) AUX_SOURCE_DIRECTORY(helpers HELPER_SRC) include_directories(/usr/local/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) configure_file("config.json" "config.json" COPYONLY) add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC})