sockscape/CMakeLists.txt

75 lines
2 KiB
CMake
Raw Normal View History

2018-08-14 15:28:14 +00:00
cmake_minimum_required(VERSION 3.12)
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-08-14 15:28:14 +00:00
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
2018-08-16 21:39:13 +00:00
if(CMAKE_COMPILER_IS_GNUCXX)
2018-08-23 06:43:45 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
2018-08-16 21:39:13 +00:00
endif()
2018-08-14 15:28:14 +00:00
2018-08-14 21:44:37 +00:00
## CLIENT BUILD ##
2018-08-23 06:43:45 +00:00
find_package(OpenGL REQUIRED)
2018-08-14 15:28:14 +00:00
find_package(GLEW REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
2018-08-14 21:44:37 +00:00
file(GLOB_RECURSE client_src
2018-08-16 21:39:13 +00:00
"src/common/*.hpp"
"src/common/*.cpp"
2018-08-14 21:44:37 +00:00
"src/client/*.hpp"
"src/client/*.cpp"
)
add_executable(client ${client_src})
target_include_directories(client
2018-08-16 21:39:13 +00:00
PRIVATE ${PROJECT_SOURCE_DIR}/src/common
PRIVATE ${PROJECT_SOURCE_DIR}/src/client
2018-08-14 21:44:37 +00:00
PRIVATE ${PROJECT_SOURCE_DIR}/include/client
PRIVATE ${OPENGL_INCLUDE_DIR}
PRIVATE ${GLEW_INCLUDE_DIR}
PRIVATE ${SDL2_INCLUDE_DIR}
2018-08-30 21:38:58 +00:00
PRIVATE ${SDL2_IMAGE_INCLUDE_DIR})
2018-08-14 21:44:37 +00:00
target_link_libraries(client
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${SDL2_LIBRARY}
2018-08-30 21:38:58 +00:00
${SDL2_IMAGE_LIBRARIES})
2018-08-14 15:28:14 +00:00
install(TARGETS client RUNTIME DESTINATION bin/client)
2018-08-14 21:44:37 +00:00
## SERVER BUILD ##
file(GLOB_RECURSE server_src
2018-08-16 21:39:13 +00:00
"src/common/*.hpp"
"src/common/*.cpp"
2018-08-14 21:44:37 +00:00
"src/server/*.hpp"
"src/server/*.cpp"
"src/server/*.c"
"src/server/*.h"
)
add_executable(server ${server_src})
2018-08-16 21:39:13 +00:00
target_include_directories(server
PRIVATE ${PROJECT_SOURCE_DIR}/src/common
PRIVATE ${PROJECT_SOURCE_DIR}/src/server)
2018-08-23 21:30:29 +00:00
install(TARGETS server RUNTIME DESTINATION bin/server)
## COMMON LIBRARIES ##
2018-08-14 15:28:14 +00:00
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(server wsock32 ws2_32)
2018-08-23 21:30:29 +00:00
target_link_libraries(client wsock32 ws2_32)
2018-08-14 15:28:14 +00:00
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(server dl pthread nsl resolv)
2018-08-23 21:30:29 +00:00
target_link_libraries(client dl pthread nsl resolv)
2018-08-14 15:28:14 +00:00
else()
target_link_libraries(server dl pthread socket nsl resolv)
2018-08-23 21:30:29 +00:00
target_link_libraries(client dl pthread socket nsl resolv)
2018-08-14 15:28:14 +00:00
endif()