|
| 1 | +cmake_minimum_required(VERSION 3.1) |
| 2 | + |
| 3 | +option(BUILD_API_EXAMPLES "Build Examples" ON) |
| 4 | +option(BUILD_API_TESTS "Build Tests" ON) |
| 5 | +project(s2client-api) |
| 6 | + |
| 7 | +# Use bin as the directory for all executables. |
| 8 | +# This will make protoc easy to find. |
| 9 | +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) |
| 10 | +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) |
| 11 | + |
| 12 | +# Windows builds subdirectories Debug/Release. |
| 13 | +# These variables will overwrite that and put binaries in bin. |
| 14 | +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin) |
| 15 | +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin) |
| 16 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin) |
| 17 | + |
| 18 | +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin) |
| 19 | +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin) |
| 20 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin) |
| 21 | + |
| 22 | +# Build with c++14 support. |
| 23 | +set(CMAKE_CXX_STANDARD 14) |
| 24 | + |
| 25 | +# Allow creating filters for projects in visual studio. |
| 26 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 27 | + |
| 28 | +# Don't build civetweb tests. |
| 29 | +set(BUILD_TESTING OFF CACHE BOOL "" FORCE) |
| 30 | +set(CIVETWEB_ENABLE_WEBSOCKETS ON CACHE BOOL "" FORCE) |
| 31 | + |
| 32 | +# Don't build civetweb with sanitizers |
| 33 | +set(CIVETWEB_ENABLE_ASAN OFF CACHE BOOL "" FORCE) |
| 34 | + |
| 35 | +# Don't build protobuf tests. |
| 36 | +set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE) |
| 37 | +set(protobuf_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) |
| 38 | + |
| 39 | +# Don't build SDL dynamic lib. |
| 40 | +set(SDL_SHARED OFF CACHE BOOL "" FORCE) |
| 41 | + |
| 42 | +# Run civetwebs cmake. |
| 43 | +add_subdirectory("contrib/civetweb") |
| 44 | + |
| 45 | +# TODO: This generates a cmake warning but we don't |
| 46 | +# want to include it in the project. |
| 47 | +#set_target_properties(c-executable PROPERTIES FOLDER contrib) |
| 48 | +set_target_properties(c-executable PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) |
| 49 | +set_target_properties(c-library c-executable PROPERTIES FOLDER contrib) |
| 50 | + |
| 51 | +# Run protobufs cmake. |
| 52 | +add_subdirectory("contrib/protobuf/cmake") |
| 53 | + |
| 54 | +set_target_properties(libprotobuf PROPERTIES FOLDER contrib) |
| 55 | +set_target_properties(libprotobuf-lite PROPERTIES FOLDER contrib) |
| 56 | +set_target_properties(libprotoc PROPERTIES FOLDER contrib) |
| 57 | +set_target_properties(protoc PROPERTIES FOLDER contrib) |
| 58 | + |
| 59 | +if (WIN32) |
| 60 | + set_target_properties(libprotobuf libprotobuf-lite libprotoc protoc PROPERTIES COMPILE_FLAGS "/W0") |
| 61 | + set_source_files_properties(${libprotobuf_files} PROPERTIES COMPILE_FLAGS "/W0") |
| 62 | + set_source_files_properties(${protobuf_SHARED_OR_STATIC} PROPERTIES COMPILE_FLAGS "/W0") |
| 63 | + set_source_files_properties(${libprotobuf_lite_files} PROPERTIES COMPILE_FLAGS "/W0") |
| 64 | + add_definitions(-D_SCL_SECURE_NO_WARNINGS) |
| 65 | +endif (WIN32) |
| 66 | + |
| 67 | +# Exclude SDL and related projects to work around linker issue. |
| 68 | +if (NOT APPLE) |
| 69 | + # Run SDLs cmake. |
| 70 | + add_subdirectory("contrib/SDL-mirror") |
| 71 | + |
| 72 | + set_target_properties(SDL2main PROPERTIES FOLDER contrib) |
| 73 | + set_target_properties(SDL2-static PROPERTIES FOLDER contrib) |
| 74 | +endif () |
| 75 | + |
| 76 | +add_subdirectory("src") |
| 77 | + |
| 78 | +# Exclude SDL and related projects to work around linker issue. |
| 79 | +if (NOT APPLE) |
| 80 | + set_target_properties(sc2renderer PROPERTIES FOLDER utilities) |
| 81 | + set_target_properties(uninstall PROPERTIES FOLDER CMakePredefinedTargets) |
| 82 | +endif () |
| 83 | + |
| 84 | +if (BUILD_API_EXAMPLES) |
| 85 | + add_subdirectory("examples") |
| 86 | +endif () |
| 87 | + |
| 88 | +if (BUILD_API_EXAMPLES) |
| 89 | + add_subdirectory("tests") |
| 90 | +endif () |
0 commit comments