2018-09-11 21:51:27 +00:00
|
|
|
cmake_minimum_required(VERSION 3.7)
|
2018-08-14 15:28:14 +00:00
|
|
|
project(sockscape)
|
|
|
|
|
2018-08-17 16:01:45 +00:00
|
|
|
string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} Debug _CMP)
|
|
|
|
if(_CMP)
|
2018-08-30 21:38:58 +00:00
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
2018-08-17 16:01:45 +00:00
|
|
|
add_definitions("-DSOSC_DEBUG")
|
|
|
|
endif()
|
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
string(COMPARE EQUAL ${SOSC_BUILD_TARGET} CLIENT _CMP)
|
|
|
|
if(_CMP)
|
|
|
|
|
|
|
|
##################
|
|
|
|
## CLIENT BUILD ##
|
|
|
|
##################
|
2018-08-14 15:28:14 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
2018-09-13 22:11:09 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
set(CMAKE_CXX_FLAGS
|
|
|
|
"${CMAKE_CXX_FLAGS} -s USE_SDL=2 --preload-file ../resources/client")
|
|
|
|
set(CMAKE_CXX_FLAGS
|
|
|
|
"${CMAKE_CXX_FLAGS} --shell-file ../src/client/shell.html")
|
|
|
|
set(CMAKE_CXX_FLAGS
|
|
|
|
"${CMAKE_CXX_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\"]'")
|
|
|
|
set(CMAKE_CXX_FLAGS
|
|
|
|
"${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_main\", \"_resize_context\"]'")
|
|
|
|
set(CMAKE_CXX_FLAGS
|
|
|
|
"${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\"]'")
|
2018-08-14 21:44:37 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
2018-08-14 15:28:14 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
file(GLOB_RECURSE client_src
|
|
|
|
#"src/common/*.hpp"
|
|
|
|
#"src/common/*.cpp"
|
|
|
|
"src/client/*.hpp"
|
|
|
|
"src/client/*.cpp"
|
|
|
|
)
|
2018-08-14 21:44:37 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
add_executable(client ${client_src})
|
2018-09-11 21:51:27 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
target_include_directories(client
|
|
|
|
#PRIVATE ${PROJECT_SOURCE_DIR}/src/common
|
|
|
|
PRIVATE ${PROJECT_SOURCE_DIR}/src/client
|
|
|
|
PRIVATE ${PROJECT_SOURCE_DIR}/include/client)
|
2018-08-14 15:28:14 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
install(TARGETS client RUNTIME DESTINATION bin/client)
|
|
|
|
else()
|
2018-08-14 21:44:37 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
##################
|
|
|
|
## SERVER BUILD ##
|
|
|
|
##################
|
2018-08-14 21:44:37 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
endif()
|
2018-08-23 21:30:29 +00:00
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
file(GLOB_RECURSE server_src
|
|
|
|
"src/common/*.hpp"
|
|
|
|
"src/common/*.cpp"
|
|
|
|
"src/server/*.hpp"
|
|
|
|
"src/server/*.cpp"
|
|
|
|
"src/server/*.c"
|
|
|
|
"src/server/*.h"
|
|
|
|
)
|
2018-08-23 21:30:29 +00:00
|
|
|
|
2018-09-18 21:46:23 +00:00
|
|
|
find_package(OpenSSL)
|
|
|
|
|
2018-09-17 19:29:56 +00:00
|
|
|
add_executable(server ${server_src})
|
|
|
|
target_include_directories(server
|
|
|
|
PRIVATE ${PROJECT_SOURCE_DIR}/src/common
|
2018-09-18 21:46:23 +00:00
|
|
|
PRIVATE ${PROJECT_SOURCE_DIR}/src/server
|
|
|
|
PRIVATE ${OPENSSL_INCLUDE_DIR})
|
|
|
|
target_link_libraries(server ${OPENSSL_LIBRARIES})
|
2018-09-17 19:29:56 +00:00
|
|
|
install(TARGETS server RUNTIME DESTINATION bin/server)
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
|
|
target_link_libraries(server wsock32 ws2_32)
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
|
|
|
target_link_libraries(server dl pthread nsl resolv)
|
|
|
|
else()
|
|
|
|
target_link_libraries(server dl pthread socket nsl resolv)
|
|
|
|
endif()
|
|
|
|
endif()
|