Update CMakeLists.txt for Linux building

This commit is contained in:
Jack Bond-Preston 2016-07-12 20:47:02 +01:00
parent 1c5b900a5a
commit 4bcedace38

View File

@ -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) ## get source ## ##############################################################
IF(MSVC) ###############################################################################
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
SET(PrecompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch")
SET(Sources ${${SourcesVar}})
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource} file(GLOB_RECURSE sources bot/*.cpp bot/*.hpp)
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)
## start setting ###############################################################################
SET (this_target TriviaBot) ## target definitions #########################################################
PROJECT(${this_target}) ###############################################################################
# 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( ## dependencies ###############################################################
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 find_package(Boost COMPONENTS system thread regex REQUIRED)
C:/Users/Jack/Documents/GitHubVisualStudio/TriviaDiscord/lib/cpr/include find_package(OpenSSL REQUIRED)
C:/Users/Jack/Documents/GitHubVisualStudio/TriviaDiscord/lib/libcurl/include find_package(CURL REQUIRED)
target_link_libraries(TriviaBot PUBLIC
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
${CURL_LIBRARIES}
pthread
) )
## section: source files include_directories(
# Add your source files here (one file per line), please SORT in alphabetical order for future maintenance ${OPENSSL_INCLUDE_DIR}
SET (${this_target}_SOURCE_FILES ${Boost_INCLUDE_DIR}
..\lib\cpr\cpr\auth.cpp ${CURL_INCLUDE_DIR}
..\lib\cpr\cpr\cookies.cpp ../lib/websocketpp
..\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
) )
## section: header files # don't know if necessary, too scared to remove
# Add your header files here(one file per line), please SORT in alphabetical order for future maintenance! add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
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
)
SOURCE_GROUP("Source Files" FILES
)
SOURCE_GROUP("Header Files" FILES
)
SOURCE_GROUP("Resource Files" FILES
)
## 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
)