From 868a759dea6b9abbf887c9e8f40c61b6a6ddbf83 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 6 Jun 2021 17:52:38 +0500 Subject: Added CPM. First attempt to improve dependencies management #15 --- CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index dbe709e..5fd03ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) project(AltCraft) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -57,6 +57,9 @@ endif(MSVC AND CMAKE_BUILD_TYPE MATCHES Release) target_link_libraries(AltCraft ${PLATFORM_LIBRARIES}) +set(CPM_USE_LOCAL_PACKAGES ON) +include(get_cpm) + ############ # LIBRARIES ############ @@ -92,9 +95,33 @@ target_link_libraries(AltCraft ${ZLIB_LIBRARIES}) target_include_directories(AltCraft PUBLIC ${ZLIB_INCLUDE_DIRS}) #Setup Lua -find_package(Lua REQUIRED) -target_link_libraries(AltCraft ${LUA_LIBRARIES}) -target_include_directories(AltCraft PUBLIC ${LUA_INCLUDE_DIR}) +CPMAddPackage( + NAME lua + GIT_REPOSITORY https://github.com/lua/lua + VERSION 5.4.3 + DOWNLOAD_ONLY YES +) +if(lua_ADDED) + # lua has no CMakeLists, so we create our own target + file(GLOB lua_sources ${lua_SOURCE_DIR}/*.c) + list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c" "${lua_SOURCE_DIR}/onelua.c") + add_library(lua STATIC ${lua_sources}) + target_include_directories(lua SYSTEM PUBLIC $) +endif() + +#Setup Sol2 +CPMAddPackage( + NAME sol2 + GIT_REPOSITORY https://github.com/ThePhD/sol2 + VERSION 3.2.2 + DOWNLOAD_ONLY YES +) +if(sol2_ADDED) + add_library(sol2 INTERFACE IMPORTED) + target_include_directories(sol2 SYSTEM INTERFACE ${sol2_SOURCE_DIR}/include) + target_link_libraries(sol2 INTERFACE lua) +endif() +target_link_libraries(AltCraft sol2) ################# # COPY RESOURCES @@ -103,3 +130,7 @@ target_include_directories(AltCraft PUBLIC ${LUA_INCLUDE_DIR}) add_custom_command(TARGET AltCraft PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cwd $) + +set_target_properties( + AltCraft PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/cwd") \ No newline at end of file -- cgit v1.2.3 From 5f8fe6a4139c71a1ed0e36b52783f2e5bf24522d Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 6 Jun 2021 21:12:26 +0500 Subject: Replaced find_package with CPMAddPackage for more libraries --- CMakeLists.txt | 78 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 16 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fd03ef..6fe0ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,6 @@ endif(MSVC AND CMAKE_BUILD_TYPE MATCHES Release) target_link_libraries(AltCraft ${PLATFORM_LIBRARIES}) -set(CPM_USE_LOCAL_PACKAGES ON) include(get_cpm) ############ @@ -74,35 +73,82 @@ if (${ENABLE_OPTICK}) target_link_libraries(AltCraft optick) endif() -#Setup SDL2 -find_package(SDL2 REQUIRED) -target_link_libraries(AltCraft ${SDL2_LIBRARY}) -target_include_directories(AltCraft PUBLIC ${SDL2_INCLUDE_DIR}) - -#Setup SDL2_net -find_package(SDL2_net REQUIRED) -target_link_libraries(AltCraft ${SDL2_NET_LIBRARIES}) -target_include_directories(AltCraft PUBLIC ${SDL2_NET_INCLUDE_DIRS}) +#Setup Threads +find_package(Threads) +target_link_libraries(AltCraft ${CMAKE_THREAD_LIBS_INIT}) #Setup OpenGL find_package(OpenGL REQUIRED) target_link_libraries(AltCraft ${OPENGL_LIBRARIES}) target_include_directories(AltCraft PUBLIC ${OPENGL_INCLUDE_DIRS}) +#Setup SDL2 +CPMAddPackage( + NAME SDL2 + GITHUB_REPOSITORY libsdl-org/SDL + VERSION 2.0.14 + GIT_TAG release-2.0.14 + OPTIONS +) +target_link_libraries(AltCraft SDL2) +set_target_properties(AltCraft SDL2 + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + ) + +#Setup SDL2_net +CPMAddPackage( + NAME SDL2_net + GITHUB_REPOSITORY libsdl-org/SDL_net + VERSION 2.0.1 + GIT_TAG release-2.0.1 + DOWNLOAD_ONLY YES +) +if(SDL2_net_ADDED) + file(GLOB SDL2_net_sources ${SDL2_net_SOURCE_DIR}/*.c) + add_library(SDL2_net STATIC ${SDL2_net_sources}) + target_link_libraries(SDL2_net SDL2) + IF (WIN32) + target_link_libraries(SDL2_net ws2_32 iphlpapi) + ENDIF() + target_include_directories(SDL2_net SYSTEM PUBLIC $) +endif() +target_link_libraries(AltCraft SDL2_net) + #Setup Zlib -find_package(ZLIB REQUIRED) -target_link_libraries(AltCraft ${ZLIB_LIBRARIES}) -target_include_directories(AltCraft PUBLIC ${ZLIB_INCLUDE_DIRS}) +CPMAddPackage( + NAME zlib + GITHUB_REPOSITORY madler/zlib + VERSION 1.2.11 + DOWNLOAD_ONLY ON +) +if(zlib_ADDED) + file(GLOB zlib_sources ${zlib_SOURCE_DIR}/*.c) + add_library(zlib STATIC ${zlib_sources}) + + include(CheckIncludeFile) + check_include_file(unistd.h Z_HAVE_UNISTD_H) + if(Z_HAVE_UNISTD_H) + target_compile_definitions(zlib PRIVATE Z_HAVE_UNISTD_H) + endif() + + if(MSVC) + target_compile_definitions(zlib PRIVATE _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE) + endif() + target_include_directories(zlib PUBLIC ${zlib_SOURCE_DIR}) +endif() +target_link_libraries(AltCraft zlib) #Setup Lua CPMAddPackage( NAME lua - GIT_REPOSITORY https://github.com/lua/lua + GITHUB_REPOSITORY lua/lua VERSION 5.4.3 DOWNLOAD_ONLY YES ) if(lua_ADDED) - # lua has no CMakeLists, so we create our own target file(GLOB lua_sources ${lua_SOURCE_DIR}/*.c) list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c" "${lua_SOURCE_DIR}/onelua.c") add_library(lua STATIC ${lua_sources}) @@ -112,7 +158,7 @@ endif() #Setup Sol2 CPMAddPackage( NAME sol2 - GIT_REPOSITORY https://github.com/ThePhD/sol2 + GITHUB_REPOSITORY ThePhD/sol2 VERSION 3.2.2 DOWNLOAD_ONLY YES ) -- cgit v1.2.3 From 83889ba33dad2743eeb2a79102a1117ec9220025 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 7 Jun 2021 07:56:57 +0500 Subject: Replaced /external/ with CPMAddPackage --- CMakeLists.txt | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 8 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fe0ca9..e9967b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ add_executable(AltCraft ${HEADERS} ${SOURCES} ${MANIFEST}) # CONFIGURATION ################ -option(ENABLE_OPTICK "Enable profiler \"Optick \"?" OFF) +option(ENABLE_OPTICK "Enable profiler \"Optick \"?" ON) #Configure Optick if (${ENABLE_OPTICK}) @@ -63,15 +63,95 @@ include(get_cpm) # LIBRARIES ############ -#Setup dependencies (GLEW, glm, nlohmann/json, easylogging++) -add_subdirectory(external) -target_include_directories(AltCraft PUBLIC external/include) -target_link_libraries(AltCraft deps) +#Setup easylogging++ +CPMAddPackage( + NAME easyloggingpp + GITHUB_REPOSITORY amrayn/easyloggingpp + VERSION 9.97.0 + OPTIONS "build_static_lib ON" +) +target_include_directories(easyloggingpp PUBLIC ${easyloggingpp_SOURCE_DIR}/src) +target_link_libraries(AltCraft easyloggingpp) -target_include_directories(AltCraft PUBLIC external/optick) -if (${ENABLE_OPTICK}) - target_link_libraries(AltCraft optick) + +CPMAddPackage( + NAME optick + GITHUB_REPOSITORY bombomby/optick + VERSION 1.3.1.0 + GIT_TAG 1.3.1.0) +target_link_libraries(AltCraft OptickCore) +set_target_properties(AltCraft OptickCore + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + ) + +#Setup glew +CPMAddPackage( + NAME glew + GITHUB_REPOSITORY Perlmint/glew-cmake + VERSION 2.2.0 + GIT_TAG glew-cmake-2.2.0 +) +target_link_libraries(AltCraft libglew_static) + +#Setup glm +CPMAddPackage( + NAME glm + GITHUB_REPOSITORY g-truc/glm + VERSION 0.9.9.8 + GIT_TAG 0.9.9.8 +) +target_link_libraries(AltCraft glm) + +#Setup stb +CPMAddPackage( + NAME stb + GITHUB_REPOSITORY nothings/stb + GIT_TAG ea2f937a01ce39795ab02b6c6e30173b4f1ed46c + DOWNLOAD_ONLY + ) +if(stb_ADDED) + add_library(stb INTERFACE) + target_include_directories(stb INTERFACE ${stb_SOURCE_DIR}) endif() +target_link_libraries(AltCraft stb) + +#Setup nlohmann json +CPMAddPackage( + NAME json + GITHUB_REPOSITORY nlohmann/json + VERSION 3.9.1 + OPTIONS + "JSON_BuildTests OFF") +target_link_libraries(AltCraft nlohmann_json::nlohmann_json) + + +#Setup Imgui +CPMAddPackage( + NAME imgui + GIT_REPOSITORY https://github.com/ocornut/imgui + VERSION 1.52 + DOWNLOAD_ONLY TRUE) +if(imgui_ADDED) + file(GLOB imgui_sources ${imgui_SOURCE_DIR}/*.cpp) + #list(REMOVE_ITEM lua_sources "${imgui_SOURCE_DIR}/lua.c" "${imgui_SOURCE_DIR}/luac.c" "${lua_SOURCE_DIR}/onelua.c") + add_library(imgui STATIC ${imgui_sources}) + target_include_directories(imgui SYSTEM PUBLIC $) +endif() +target_link_libraries(AltCraft imgui) + +#Setup ./external/ +#file(GLOB external_src ${CMAKE_CURRENT_SOURCE_DIR}/external/src/*) +#add_library(external ${external_src}) +#target_include_directories(external INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/external/include) +#target_link_libraries(AltCraft external) + +#target_include_directories(AltCraft PUBLIC external/optick) +#if (${ENABLE_OPTICK}) +# target_link_libraries(AltCraft optick) +#endif() #Setup Threads find_package(Threads) -- cgit v1.2.3 From 5c9cd1c84e9d25c2ef1440f3aa7019c62e4aa02d Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 7 Jun 2021 14:37:40 +0500 Subject: Refactored CMakeLists.txt --- CMakeLists.txt | 309 +++++++++++++++++++++++---------------------------------- 1 file changed, 126 insertions(+), 183 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index e9967b6..96d8e3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,193 +1,106 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.9) project(AltCraft) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +include(get_cpm) if (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release) endif() -########## -# SOURCES -########## - -file(GLOB_RECURSE MANIFEST "./src/*.manifest") -file(GLOB_RECURSE SOURCES "./src/*.cpp") -file(GLOB_RECURSE HEADERS "./src/*.hpp") +############ +# LIBRARIES +############ -add_executable(AltCraft ${HEADERS} ${SOURCES} ${MANIFEST}) -################ -# CONFIGURATION -################ +find_package(Threads) -option(ENABLE_OPTICK "Enable profiler \"Optick \"?" ON) -#Configure Optick -if (${ENABLE_OPTICK}) - add_definitions(-DUSE_OPTICK=1) -else() - add_definitions(-DUSE_OPTICK=0) -endif() +find_package(OpenGL REQUIRED) -#Configure easlylogging++ -set(LOGGER_DEFINITIONS "-DELPP_THREAD_SAFE -DELPP_FEATURE_PERFORMANCE_TRACKING") -if (LINUX) - set(LOGGER_DENITIONS "${LOGGER_DEFINITIPNS} -DELPP_FEATURE_CRASH_LOG -DELPP_STL_LOGGING") -endif () -add_definitions(${LOGGER_DEFINITIONS}) - -#Set compiler's flags and setup platfrom-dependent libraries -if (CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wno-error=unused-parameter") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -p") - set(PLATFORM_LIBRARIES "stdc++fs") -endif () -if(MSVC AND CMAKE_BUILD_TYPE MATCHES Release) - target_compile_definitions(AltCraft PRIVATE USE_SDL_MAIN) - set_target_properties(AltCraft PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") -endif(MSVC AND CMAKE_BUILD_TYPE MATCHES Release) +CPMAddPackage("gh:g-truc/glm@0.9.9.8#0.9.9.8") -target_link_libraries(AltCraft ${PLATFORM_LIBRARIES}) -include(get_cpm) +CPMAddPackage("gh:bombomby/optick@1.3.1.0#1.3.1.0") -############ -# LIBRARIES -############ -#Setup easylogging++ CPMAddPackage( - NAME easyloggingpp - GITHUB_REPOSITORY amrayn/easyloggingpp - VERSION 9.97.0 - OPTIONS "build_static_lib ON" + GITHUB_REPOSITORY Perlmint/glew-cmake + VERSION 2.2.0 + GIT_TAG glew-cmake-2.2.0 + OPTIONS + "glew-cmake_BUILD_SHARED OFF" ) -target_include_directories(easyloggingpp PUBLIC ${easyloggingpp_SOURCE_DIR}/src) -target_link_libraries(AltCraft easyloggingpp) CPMAddPackage( - NAME optick - GITHUB_REPOSITORY bombomby/optick - VERSION 1.3.1.0 - GIT_TAG 1.3.1.0) -target_link_libraries(AltCraft OptickCore) -set_target_properties(AltCraft OptickCore - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - ) - -#Setup glew + NAME json + GITHUB_REPOSITORY nlohmann/json + VERSION 3.9.1 + OPTIONS + "JSON_BuildTests OFF" +) + + CPMAddPackage( - NAME glew - GITHUB_REPOSITORY Perlmint/glew-cmake - VERSION 2.2.0 - GIT_TAG glew-cmake-2.2.0 + NAME SDL2 + GITHUB_REPOSITORY libsdl-org/SDL + VERSION 2.0.14 + GIT_TAG release-2.0.14 + OPTIONS + "SDL_SHARED ON" + "SDL_STATIC OFF" ) -target_link_libraries(AltCraft libglew_static) -#Setup glm + CPMAddPackage( - NAME glm - GITHUB_REPOSITORY g-truc/glm - VERSION 0.9.9.8 - GIT_TAG 0.9.9.8 + NAME easyloggingpp + GITHUB_REPOSITORY amrayn/easyloggingpp + VERSION 9.97.0 + OPTIONS "build_static_lib ON" ) -target_link_libraries(AltCraft glm) +target_include_directories(easyloggingpp PUBLIC ${easyloggingpp_SOURCE_DIR}/src) +target_compile_definitions(easyloggingpp PUBLIC ELPP_THREAD_SAFE ELPP_FEATURE_PERFORMANCE_TRACKING) +if (LINUX) + target_compile_definitions(easyloggingpp PUBLIC ELPP_FEATURE_CRASH_LOG ELPP_STL_LOGGING) +endif () + -#Setup stb CPMAddPackage( - NAME stb - GITHUB_REPOSITORY nothings/stb - GIT_TAG ea2f937a01ce39795ab02b6c6e30173b4f1ed46c - DOWNLOAD_ONLY - ) + NAME stb + GITHUB_REPOSITORY nothings/stb + GIT_TAG ea2f937a01ce39795ab02b6c6e30173b4f1ed46c + DOWNLOAD_ONLY TRUE +) if(stb_ADDED) - add_library(stb INTERFACE) - target_include_directories(stb INTERFACE ${stb_SOURCE_DIR}) + add_library(stb INTERFACE) + target_include_directories(stb INTERFACE ${stb_SOURCE_DIR}) endif() -target_link_libraries(AltCraft stb) - -#Setup nlohmann json -CPMAddPackage( - NAME json - GITHUB_REPOSITORY nlohmann/json - VERSION 3.9.1 - OPTIONS - "JSON_BuildTests OFF") -target_link_libraries(AltCraft nlohmann_json::nlohmann_json) -#Setup Imgui CPMAddPackage( - NAME imgui - GIT_REPOSITORY https://github.com/ocornut/imgui - VERSION 1.52 - DOWNLOAD_ONLY TRUE) + NAME imgui + GITHUB_REPOSITORY ocornut/imgui + VERSION 1.52 + DOWNLOAD_ONLY TRUE +) if(imgui_ADDED) - file(GLOB imgui_sources ${imgui_SOURCE_DIR}/*.cpp) - #list(REMOVE_ITEM lua_sources "${imgui_SOURCE_DIR}/lua.c" "${imgui_SOURCE_DIR}/luac.c" "${lua_SOURCE_DIR}/onelua.c") - add_library(imgui STATIC ${imgui_sources}) - target_include_directories(imgui SYSTEM PUBLIC $) + file(GLOB imgui_sources ${imgui_SOURCE_DIR}/*.cpp) + add_library(imgui STATIC ${imgui_sources}) + target_include_directories(imgui SYSTEM PUBLIC $) endif() -target_link_libraries(AltCraft imgui) - -#Setup ./external/ -#file(GLOB external_src ${CMAKE_CURRENT_SOURCE_DIR}/external/src/*) -#add_library(external ${external_src}) -#target_include_directories(external INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/external/include) -#target_link_libraries(AltCraft external) -#target_include_directories(AltCraft PUBLIC external/optick) -#if (${ENABLE_OPTICK}) -# target_link_libraries(AltCraft optick) -#endif() -#Setup Threads -find_package(Threads) -target_link_libraries(AltCraft ${CMAKE_THREAD_LIBS_INIT}) - -#Setup OpenGL -find_package(OpenGL REQUIRED) -target_link_libraries(AltCraft ${OPENGL_LIBRARIES}) -target_include_directories(AltCraft PUBLIC ${OPENGL_INCLUDE_DIRS}) - -#Setup SDL2 -CPMAddPackage( - NAME SDL2 - GITHUB_REPOSITORY libsdl-org/SDL - VERSION 2.0.14 - GIT_TAG release-2.0.14 - OPTIONS -) -target_link_libraries(AltCraft SDL2) -set_target_properties(AltCraft SDL2 - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - ) - -#Setup SDL2_net CPMAddPackage( - NAME SDL2_net - GITHUB_REPOSITORY libsdl-org/SDL_net - VERSION 2.0.1 - GIT_TAG release-2.0.1 - DOWNLOAD_ONLY YES + NAME SDL2_net + GITHUB_REPOSITORY libsdl-org/SDL_net + VERSION 2.0.1 + GIT_TAG release-2.0.1 + DOWNLOAD_ONLY YES ) if(SDL2_net_ADDED) file(GLOB SDL2_net_sources ${SDL2_net_SOURCE_DIR}/*.c) + list(REMOVE_ITEM SDL2_net_sources "${SDL2_net_SOURCE_DIR}/chatd.c") add_library(SDL2_net STATIC ${SDL2_net_sources}) target_link_libraries(SDL2_net SDL2) IF (WIN32) @@ -195,14 +108,13 @@ if(SDL2_net_ADDED) ENDIF() target_include_directories(SDL2_net SYSTEM PUBLIC $) endif() -target_link_libraries(AltCraft SDL2_net) -#Setup Zlib + CPMAddPackage( - NAME zlib - GITHUB_REPOSITORY madler/zlib - VERSION 1.2.11 - DOWNLOAD_ONLY ON + NAME zlib + GITHUB_REPOSITORY madler/zlib + VERSION 1.2.11 + DOWNLOAD_ONLY ON ) if(zlib_ADDED) file(GLOB zlib_sources ${zlib_SOURCE_DIR}/*.c) @@ -219,44 +131,75 @@ if(zlib_ADDED) endif() target_include_directories(zlib PUBLIC ${zlib_SOURCE_DIR}) endif() -target_link_libraries(AltCraft zlib) -#Setup Lua + CPMAddPackage( - NAME lua - GITHUB_REPOSITORY lua/lua - VERSION 5.4.3 - DOWNLOAD_ONLY YES + NAME lua + GITHUB_REPOSITORY lua/lua + VERSION 5.4.3 + DOWNLOAD_ONLY YES ) if(lua_ADDED) - file(GLOB lua_sources ${lua_SOURCE_DIR}/*.c) - list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c" "${lua_SOURCE_DIR}/onelua.c") - add_library(lua STATIC ${lua_sources}) - target_include_directories(lua SYSTEM PUBLIC $) + file(GLOB lua_sources ${lua_SOURCE_DIR}/*.c) + list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c" "${lua_SOURCE_DIR}/onelua.c") + add_library(lua STATIC ${lua_sources}) + target_include_directories(lua SYSTEM PUBLIC $) endif() -#Setup Sol2 + CPMAddPackage( - NAME sol2 - GITHUB_REPOSITORY ThePhD/sol2 - VERSION 3.2.2 - DOWNLOAD_ONLY YES + NAME sol2 + GITHUB_REPOSITORY ThePhD/sol2 + VERSION 3.2.2 + DOWNLOAD_ONLY YES ) if(sol2_ADDED) - add_library(sol2 INTERFACE IMPORTED) - target_include_directories(sol2 SYSTEM INTERFACE ${sol2_SOURCE_DIR}/include) - target_link_libraries(sol2 INTERFACE lua) + add_library(sol2 INTERFACE IMPORTED) + target_include_directories(sol2 SYSTEM INTERFACE ${sol2_SOURCE_DIR}/include) + target_link_libraries(sol2 INTERFACE lua) endif() -target_link_libraries(AltCraft sol2) -################# -# COPY RESOURCES -################# -add_custom_command(TARGET AltCraft PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_SOURCE_DIR}/cwd $) +########### +# AltCraft +########### + +file(GLOB ac_manifest "./src/*.manifest") +file(GLOB ac_sources "./src/*.cpp") + +add_executable(AltCraft ${ac_sources} ${ac_manifest}) + +target_compile_features(AltCraft PRIVATE cxx_std_17) + +target_link_libraries(AltCraft + Threads::Threads + OpenGL::GL + glm + stb + easyloggingpp + libglew_static + nlohmann_json::nlohmann_json + imgui + SDL2 + SDL2main + SDL2_net + OptickCore + zlib + sol2 +) + +set_target_properties(AltCraft SDL2 OptickCore PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} +) -set_target_properties( - AltCraft PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/cwd") \ No newline at end of file +set_target_properties(AltCraft PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/cwd/ + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) + +set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT AltCraft) + +if(MSVC AND CMAKE_BUILD_TYPE MATCHES Release) + set_target_properties(AltCraft PROPERTIES WIN32_EXECUTABLE ON) +endif() -- cgit v1.2.3 From 1e9fe310b6fdd4400048e2d5749cc0fb2437a58e Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 7 Jun 2021 16:00:05 +0500 Subject: Fix Travis-CI build error --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 96d8e3e..3343b7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.14) project(AltCraft) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) include(get_cpm) @@ -7,11 +7,11 @@ if (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release) endif() + ############ # LIBRARIES ############ - find_package(Threads) -- cgit v1.2.3