fix: cmake stuff

remove: docker
This commit is contained in:
Tobias Reisinger 2019-09-01 19:34:50 +02:00
parent 086102c2fb
commit f3c03739ca

View file

@ -1,74 +1,61 @@
cmake_minimum_required (VERSION 3.2) cmake_minimum_required (VERSION 3.2)
Project(core) project(core)
link_directories(/usr/local/lib) include(CheckIncludeFileCXX)
link_libraries(drogon trantor pthread dl)
IF (CMAKE_SYSTEM_NAME MATCHES "Linux") check_include_file_cxx(any HAS_ANY)
EXEC_PROGRAM (gcc ARGS "--version | grep '^gcc'|awk '{print $3}' | sed s'/)//g' | sed s'/-.*//g'" OUTPUT_VARIABLE version) check_include_file_cxx(string_view HAS_STRING_VIEW)
MESSAGE(STATUS "This is gcc version:: " ${version}) if(HAS_ANY AND HAS_STRING_VIEW)
if(version LESS 5.4.0) set(CMAKE_CXX_STANDARD 17)
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() else()
set(CMAKE_CXX_STD_FLAGS c++17) set(CMAKE_CXX_STANDARD 14)
endif() endif()
if(CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_EXTENSIONS OFF)
##########
# 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})
##########
find_package(Drogon CONFIG REQUIRED)
include_directories(${DROGON_INCLUDE_DIRS})
link_libraries(${DROGON_LIBRARIES})
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")
endif() endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -std=${CMAKE_CXX_STD_FLAGS}") aux_source_directory(./ SRC_DIR)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -std=${CMAKE_CXX_STD_FLAGS}") 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)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/) file(GLOB SCP_LIST ${CMAKE_CURRENT_SOURCE_DIR}/views/*.csp)
foreach(cspFile ${SCP_LIST})
#jsoncpp message(STATUS "cspFile:" ${cspFile})
find_package (Jsoncpp REQUIRED) EXEC_PROGRAM(basename ARGS "${cspFile} .csp" OUTPUT_VARIABLE classname)
include_directories(${JSONCPP_INCLUDE_DIRS}) message(STATUS "view classname:" ${classname})
link_libraries(${JSONCPP_LIBRARIES}) ADD_CUSTOM_COMMAND(OUTPUT ${classname}.h ${classname}.cc
COMMAND drogon_ctl
#uuid ARGS create view ${cspFile}
find_package (UUID REQUIRED) DEPENDS ${cspFile}
include_directories(${UUID_INCLUDE_DIR}) VERBATIM )
link_libraries(${UUID_LIBRARIES}) set(VIEWSRC ${VIEWSRC} ${classname}.cc)
endforeach()
#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 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}) include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC})
configure_file("config.json" "config.json" COPYONLY)
add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC})