Update CMakeLists.txt for Linux building
This commit is contained in:
parent
1c5b900a5a
commit
4bcedace38
@ -1,123 +1,43 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(TriviaBot)
|
||||
|
||||
## section: Macro
|
||||
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
|
||||
IF(MSVC)
|
||||
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
|
||||
SET(PrecompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch")
|
||||
SET(Sources ${${SourcesVar}})
|
||||
###############################################################################
|
||||
## get source ## ##############################################################
|
||||
###############################################################################
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
|
||||
PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\""
|
||||
OBJECT_OUTPUTS "${PrecompiledBinary}")
|
||||
SET_SOURCE_FILES_PROPERTIES(${Sources}
|
||||
PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledBinary}\" /FI\"${PrecompiledBinary}\" /Fp\"${PrecompiledBinary}\""
|
||||
OBJECT_DEPENDS "${PrecompiledBinary}")
|
||||
# Add precompiled header to SourcesVar
|
||||
LIST(APPEND ${SourcesVar} ${PrecompiledSource})
|
||||
ENDIF(MSVC)
|
||||
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)
|
||||
file(GLOB_RECURSE sources bot/*.cpp bot/*.hpp)
|
||||
|
||||
## start setting
|
||||
SET (this_target TriviaBot)
|
||||
PROJECT(${this_target})
|
||||
###############################################################################
|
||||
## target definitions #########################################################
|
||||
###############################################################################
|
||||
|
||||
# add the data to the target, so it becomes visible in some IDE
|
||||
add_executable(TriviaBot ${sources})
|
||||
|
||||
# just for example add some compiler flags
|
||||
target_compile_options(TriviaBot PUBLIC -std=c++14 -Wall -Wfloat-conversion -g)
|
||||
|
||||
## section: include directory
|
||||
INCLUDE_DIRECTORIES(
|
||||
C:/Users/Jack/Documents/GitHubVisualStudio/TriviaDiscord/lib/boost_1_61_0
|
||||
C:/Users/Jack/Documents/GitHubVisualStudio/TriviaDiscord/lib/openssl/include
|
||||
C:/Users/Jack/Documents/GitHubVisualStudio/TriviaDiscord/lib/websocketpp
|
||||
C:/Users/Jack/Documents/GitHubVisualStudio/TriviaDiscord/lib/cpr/include
|
||||
C:/Users/Jack/Documents/GitHubVisualStudio/TriviaDiscord/lib/libcurl/include
|
||||
)
|
||||
###############################################################################
|
||||
## dependencies ###############################################################
|
||||
###############################################################################
|
||||
|
||||
## section: source files
|
||||
# Add your source files here (one file per line), please SORT in alphabetical order for future maintenance
|
||||
SET (${this_target}_SOURCE_FILES
|
||||
..\lib\cpr\cpr\auth.cpp
|
||||
..\lib\cpr\cpr\cookies.cpp
|
||||
..\lib\cpr\cpr\cprtypes.cpp
|
||||
..\lib\cpr\cpr\digest.cpp
|
||||
..\lib\cpr\cpr\error.cpp
|
||||
..\lib\cpr\cpr\multipart.cpp
|
||||
..\lib\cpr\cpr\parameters.cpp
|
||||
..\lib\cpr\cpr\payload.cpp
|
||||
..\lib\cpr\cpr\proxies.cpp
|
||||
..\lib\cpr\cpr\session.cpp
|
||||
..\lib\cpr\cpr\util.cpp
|
||||
bot\APIHelper.cpp
|
||||
bot\ClientConnection.cpp
|
||||
bot\GatewayHandler.cpp
|
||||
bot\http\HTTPHelper.cpp
|
||||
bot\TriviaBot.cpp
|
||||
bot\TriviaGame.cpp
|
||||
data_management\LoadDB.cpp
|
||||
)
|
||||
find_package(Boost COMPONENTS system thread regex REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
|
||||
## section: header files
|
||||
# Add your header files here(one file per line), please SORT in alphabetical order for future maintenance!
|
||||
SET(${this_target}_HEADER_FILES
|
||||
bot\ClientConnection.hpp
|
||||
bot\APIHelper.hpp
|
||||
bot\data_structures\Channel.hpp
|
||||
bot\data_structures\Guild.hpp
|
||||
bot\data_structures\User.hpp
|
||||
bot\GatewayHandler.hpp
|
||||
bot\HTTP\HTTPHelper.hpp
|
||||
bot\json\json.hpp
|
||||
bot\TriviaGame.hpp
|
||||
)
|
||||
target_link_libraries(TriviaBot PUBLIC
|
||||
${Boost_LIBRARIES}
|
||||
${OPENSSL_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
pthread
|
||||
)
|
||||
|
||||
SOURCE_GROUP("Source Files" FILES
|
||||
|
||||
)
|
||||
SOURCE_GROUP("Header Files" FILES
|
||||
|
||||
)
|
||||
SOURCE_GROUP("Resource Files" FILES
|
||||
|
||||
)
|
||||
include_directories(
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${Boost_INCLUDE_DIR}
|
||||
${CURL_INCLUDE_DIR}
|
||||
../lib/websocketpp
|
||||
)
|
||||
|
||||
|
||||
## section: precompiled header
|
||||
#ADD_MSVC_PRECOMPILED_HEADER("precompiled.h" "precompiled.cpp" MySources)
|
||||
#ADD_LIBRARY(MyLibrary ${MySources})
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(${this_target}_HEADER_FILES
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
LIST(APPEND ${this_target}_SOURCE_FILES ${${this_target}_HEADER_FILES})
|
||||
|
||||
## section: add definitions
|
||||
# add prefix -D. example> -DSHP
|
||||
# - DO NOT add the following definitions(already defined in ${OSP_DEFINITIONS}:
|
||||
# -DSHP, -DWIN32, -D_WINDOWS, -D_DEBUG, -D_USRDLL, -D_CRT_SECURE_NO_DEPRECATE
|
||||
ADD_DEFINITIONS(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
)
|
||||
|
||||
## section: add target
|
||||
|
||||
ADD_EXECUTABLE(${this_target} ${${this_target}_SOURCE_FILES})
|
||||
|
||||
## section: add dependency
|
||||
# dependency determines overall build order.
|
||||
ADD_DEPENDENCIES(${this_target}
|
||||
libcurl.lib
|
||||
sqlite3.lib
|
||||
libeay32.lib
|
||||
ssleay32.lib
|
||||
sqlite3.lib
|
||||
libeay32.lib
|
||||
)
|
||||
|
||||
## section: set link libraries
|
||||
TARGET_LINK_LIBRARIES( ${this_target}
|
||||
libcurl.lib
|
||||
sqlite3.lib
|
||||
libeay32.lib
|
||||
ssleay32.lib
|
||||
sqlite3.lib
|
||||
libeay32.lib
|
||||
)
|
||||
# don't know if necessary, too scared to remove
|
||||
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
|
Loading…
Reference in New Issue
Block a user