Merge pull request #435 from Ygrik2003/Refactoring-cmake
Refactoring cmake
This commit is contained in:
parent
a8eda192af
commit
6c3d2d0907
7
.github/workflows/macos.yml
vendored
7
.github/workflows/macos.yml
vendored
@ -17,12 +17,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies from brew
|
- name: Install dependencies from brew
|
||||||
run: |
|
run: |
|
||||||
brew install glfw3 glew libpng openal-soft luajit libvorbis skypjack/entt/entt googletest
|
brew install glfw3 glew libpng openal-soft luajit libvorbis skypjack/entt/entt googletest glm
|
||||||
|
|
||||||
- name: Install specific version of GLM
|
|
||||||
run: |
|
|
||||||
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/5c7655a866646aa4b857c002b8ae5465b9d26f65/Formula/g/glm.rb
|
|
||||||
brew install --formula glm.rb
|
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_APPDIR=1
|
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_APPDIR=1
|
||||||
|
|||||||
11
.github/workflows/windows-clang.yml
vendored
11
.github/workflows/windows-clang.yml
vendored
@ -28,9 +28,7 @@ jobs:
|
|||||||
msystem: clang64
|
msystem: clang64
|
||||||
install: >-
|
install: >-
|
||||||
mingw-w64-clang-x86_64-toolchain
|
mingw-w64-clang-x86_64-toolchain
|
||||||
mingw-w64-clang-x86_64-cmake
|
mingw-w64-clang-x86_64-cmake
|
||||||
mingw-w64-clang-x86_64-make
|
|
||||||
mingw-w64-clang-x86_64-luajit
|
|
||||||
git
|
git
|
||||||
- name: Set up vcpkg
|
- name: Set up vcpkg
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
@ -41,11 +39,12 @@ jobs:
|
|||||||
./vcpkg integrate install
|
./vcpkg integrate install
|
||||||
cd ..
|
cd ..
|
||||||
- name: Configure project with CMake and vcpkg
|
- name: Configure project with CMake and vcpkg
|
||||||
|
env:
|
||||||
|
VCPKG_DEFAULT_TRIPLET: x64-mingw-static
|
||||||
|
VCPKG_DEFAULT_HOST_TRIPLET: x64-mingw-static
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
run: |
|
run: |
|
||||||
export VCPKG_DEFAULT_TRIPLET=x64-mingw-static
|
export VCPKG_ROOT=$(pwd)/vcpkg
|
||||||
export VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-static
|
|
||||||
export VCPKG_ROOT=./vcpkg
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake ..
|
cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake ..
|
||||||
|
|||||||
@ -1,84 +1,47 @@
|
|||||||
cmake_minimum_required(VERSION 3.26)
|
cmake_minimum_required(VERSION 3.26)
|
||||||
project(VoxelEngine)
|
project(VoxelEngine)
|
||||||
|
|
||||||
option(VOXELENGINE_BUILD_APPDIR "" OFF)
|
|
||||||
option(VOXELENGINE_BUILD_TESTS "" OFF)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} --version)
|
||||||
|
|
||||||
|
option(VOXELENGINE_BUILD_APPDIR "Pack linux build" OFF)
|
||||||
|
option(VOXELENGINE_BUILD_TESTS "Build tests" OFF)
|
||||||
|
|
||||||
|
# Need for static compilation on Windows with MSVC clang TODO: Make single build
|
||||||
|
# on Windows to avoid dependence on combinations of platforms and compilers and
|
||||||
|
# make it independent
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
# We use two types linking: for clang build is static (vcpkg triplet
|
# We use two types linking: for clang build is static (vcpkg triplet
|
||||||
# x64-windows-static) and for msvc build is dynamic linking (vcpkg triplet
|
# x64-windows-static) and for msvc build is dynamic linking (vcpkg triplet
|
||||||
# x64-windows) By default CMAKE_MSVC_RUNTIME_LIBRARY set by
|
# x64-windows) By default CMAKE_MSVC_RUNTIME_LIBRARY set by
|
||||||
# MultiThreaded$<$<CONFIG:Debug>:Debug>DLL
|
# MultiThreaded$<$<CONFIG:Debug>:Debug>DLL
|
||||||
if(VCPKG_TARGET_TRIPLET MATCHES "static")
|
if(VCPKG_TARGET_TRIPLET MATCHES "static")
|
||||||
|
# Need for MSVC clang
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_executable(${PROJECT_NAME} src/main.cpp)
|
add_executable(VoxelEngine src/main.cpp)
|
||||||
target_include_directories(${PROJECT_NAME}
|
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
||||||
|
|
||||||
if(VOXELENGINE_BUILD_APPDIR)
|
if(VOXELENGINE_BUILD_APPDIR)
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
target_link_libraries(VoxelEngine PRIVATE VoxelEngineSrc
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
$<$<PLATFORM_ID:Windows>:winmm>)
|
||||||
set(CMAKE_BUILD_TYPE
|
|
||||||
Release
|
|
||||||
CACHE STRING "Build type" FORCE)
|
|
||||||
endif()
|
|
||||||
if((CMAKE_BUILD_TYPE EQUAL "Release") OR (CMAKE_BUILD_TYPE EQUAL
|
|
||||||
"RelWithDebInfo"))
|
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /MT /O2)
|
|
||||||
else()
|
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
|
|
||||||
endif()
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} /source-charset:UTF-8 /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR"
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
target_compile_options(
|
|
||||||
${PROJECT_NAME}
|
|
||||||
PRIVATE -Wall
|
|
||||||
-Wextra
|
|
||||||
# additional warnings
|
|
||||||
-Wformat-nonliteral
|
|
||||||
-Wcast-align
|
|
||||||
-Wpointer-arith
|
|
||||||
-Wundef
|
|
||||||
-Wwrite-strings
|
|
||||||
-Wno-unused-parameter)
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE -Og)
|
|
||||||
endif()
|
|
||||||
if(WIN32)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
target_link_options(VoxelEngine PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries(${PROJECT_NAME} VoxelEngineSrc winmm)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} VoxelEngineSrc ${CMAKE_DL_LIBS})
|
|
||||||
|
|
||||||
# Deploy res to build dir
|
# Deploy res to build dir
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${PROJECT_NAME}
|
TARGET VoxelEngine
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND
|
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
||||||
${CMAKE_COMMAND} -E copy_directory_if_different
|
${CMAKE_CURRENT_SOURCE_DIR}/res $<TARGET_FILE_DIR:VoxelEngine>/res)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/res $<TARGET_FILE_DIR:${PROJECT_NAME}>/res)
|
|
||||||
|
|
||||||
if(VOXELENGINE_BUILD_TESTS)
|
if(VOXELENGINE_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|||||||
@ -14,6 +14,34 @@
|
|||||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||||
"VOXELENGINE_BUILD_TESTS": "ON"
|
"VOXELENGINE_BUILD_TESTS": "ON"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-ninja-gnu-linux",
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"rhs": "${hostSystemName}",
|
||||||
|
"lhs": "Linux"
|
||||||
|
},
|
||||||
|
"generator": "Ninja Multi-Config",
|
||||||
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"cacheVariables": {
|
||||||
|
"VOXELENGINE_BUILD_TESTS": "ON",
|
||||||
|
"VOXELENGINE_BUILD_APPDIR": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-ninja-clang-macos",
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"rhs": "${hostSystemName}",
|
||||||
|
"lhs": "Darwin"
|
||||||
|
},
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"cacheVariables": {
|
||||||
|
"VOXELENGINE_BUILD_TESTS": "ON",
|
||||||
|
"VOXELENGINE_BUILD_APPDIR": "ON"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"buildPresets": [
|
"buildPresets": [
|
||||||
@ -21,6 +49,16 @@
|
|||||||
"name": "default-vs-msvc-windows",
|
"name": "default-vs-msvc-windows",
|
||||||
"configurePreset": "default-vs-msvc-windows",
|
"configurePreset": "default-vs-msvc-windows",
|
||||||
"configuration": "Debug"
|
"configuration": "Debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-ninja-gnu-linux",
|
||||||
|
"configurePreset": "default-ninja-gnu-linux",
|
||||||
|
"configuration": "Debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-ninja-clang-macos",
|
||||||
|
"configurePreset": "default-ninja-clang-macos",
|
||||||
|
"configuration": "Debug"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"testPresets": [
|
"testPresets": [
|
||||||
@ -30,6 +68,20 @@
|
|||||||
"output": {
|
"output": {
|
||||||
"outputOnFailure": true
|
"outputOnFailure": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-ninja-gnu-linux",
|
||||||
|
"configurePreset": "default-ninja-gnu-linux",
|
||||||
|
"output": {
|
||||||
|
"outputOnFailure": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-ninja-clang-macos",
|
||||||
|
"configurePreset": "default-ninja-clang-macos",
|
||||||
|
"output": {
|
||||||
|
"outputOnFailure": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1,87 +1,122 @@
|
|||||||
project(VoxelEngineSrc)
|
project(VoxelEngineSrc)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
file(GLOB_RECURSE headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
||||||
|
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||||
|
list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
||||||
|
|
||||||
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
add_library(VoxelEngineSrc STATIC ${sources} ${headers})
|
||||||
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
|
||||||
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
|
find_package(glm REQUIRED)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
# specific for vcpkg
|
# specific for vcpkg
|
||||||
find_package(OpenAL CONFIG REQUIRED)
|
find_package(OpenAL CONFIG REQUIRED)
|
||||||
set(OPENAL_LIBRARY OpenAL::OpenAL)
|
|
||||||
else()
|
else()
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
|
find_package(glfw3 REQUIRED)
|
||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
find_package(EnTT REQUIRED)
|
find_package(EnTT REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBS "")
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
# Use directly linking to lib instead PkgConfig (because pkg-config dont
|
|
||||||
# install on windows as default) TODO: Do it with findLua.
|
|
||||||
if(MSVC)
|
|
||||||
set(LUA_INCLUDE_DIR
|
|
||||||
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit"
|
|
||||||
)
|
|
||||||
find_package(Lua REQUIRED)
|
|
||||||
else()
|
|
||||||
# Used for mingw-clang cross compiling from msys2
|
|
||||||
set(LIBS ${LIBS} luajit-5.1)
|
|
||||||
endif()
|
|
||||||
find_package(glfw3 REQUIRED)
|
|
||||||
find_package(glm REQUIRED)
|
|
||||||
find_package(vorbis REQUIRED)
|
find_package(vorbis REQUIRED)
|
||||||
set(VORBISLIB Vorbis::vorbis Vorbis::vorbisfile)
|
if(VCPKG_TARGET_TRIPLET MATCHES "static")
|
||||||
|
add_library(luajit STATIC IMPORTED)
|
||||||
|
set_target_properties(
|
||||||
|
luajit
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_LOCATION
|
||||||
|
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/lib/libluajit-5.1.a"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_library(luajit SHARED IMPORTED)
|
||||||
|
set_target_properties(
|
||||||
|
luajit
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_LOCATION
|
||||||
|
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/bin/lua51.dll"
|
||||||
|
IMPORTED_IMPLIB
|
||||||
|
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/lib/lua51.lib"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
elseif(APPLE)
|
add_library(luajit::luajit ALIAS luajit)
|
||||||
find_package(PkgConfig)
|
|
||||||
pkg_check_modules(LUAJIT REQUIRED luajit)
|
|
||||||
pkg_check_modules(VORBIS REQUIRED vorbis vorbisfile)
|
|
||||||
set(LUA_INCLUDE_DIR "/opt/homebrew/include/luajit-2.1")
|
|
||||||
set(LUA_LIBRARIES "/opt/homebrew/lib/libluajit-5.1.a")
|
|
||||||
message(STATUS "LUA Libraries: ${LUA_LIBRARIES}")
|
|
||||||
message(STATUS "LUA Include Dir: ${LUA_INCLUDE_DIR}")
|
|
||||||
|
|
||||||
set(VORBISLIB ${VORBIS_LDFLAGS})
|
|
||||||
message(STATUS "Vorbis Lib: ${VORBIS_LDFLAGS}")
|
|
||||||
else()
|
else()
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
pkg_check_modules(LUAJIT REQUIRED luajit)
|
|
||||||
pkg_check_modules(VORBIS REQUIRED vorbis vorbisfile)
|
pkg_check_modules(luajit REQUIRED IMPORTED_TARGET luajit)
|
||||||
set(LUA_LIBRARIES ${LUAJIT_LIBRARIES})
|
pkg_check_modules(vorbis REQUIRED IMPORTED_TARGET vorbis)
|
||||||
set(LUA_INCLUDE_DIR ${LUAJIT_INCLUDE_DIRS})
|
pkg_check_modules(vorbisfile REQUIRED IMPORTED_TARGET vorbisfile)
|
||||||
set(VORBISLIB ${VORBIS_LDFLAGS})
|
add_library(Vorbis::vorbis ALIAS PkgConfig::vorbis)
|
||||||
|
add_library(Vorbis::vorbisfile ALIAS PkgConfig::vorbisfile)
|
||||||
|
add_library(luajit::luajit ALIAS PkgConfig::luajit)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX)
|
target_include_directories(VoxelEngineSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
find_package(glfw3 3.3 REQUIRED)
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
set(LIBS ${LIBS} Threads::Threads)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(${LUA_INCLUDE_DIR})
|
|
||||||
include_directories(${CURL_INCLUDE_DIR})
|
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
${PROJECT_NAME}
|
VoxelEngineSrc
|
||||||
${LIBS}
|
PRIVATE glfw
|
||||||
glfw
|
OpenGL::GL
|
||||||
OpenGL::GL
|
GLEW::GLEW
|
||||||
${OPENAL_LIBRARY}
|
ZLIB::ZLIB
|
||||||
GLEW::GLEW
|
PNG::PNG
|
||||||
ZLIB::ZLIB
|
CURL::libcurl
|
||||||
PNG::PNG
|
OpenAL::OpenAL
|
||||||
CURL::libcurl
|
Vorbis::vorbis
|
||||||
${VORBISLIB}
|
Vorbis::vorbisfile
|
||||||
${LUA_LIBRARIES}
|
luajit::luajit
|
||||||
${CMAKE_DL_LIBS})
|
PUBLIC glm::glm # Need public for src/delegates.hpp, which including to
|
||||||
|
# main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(
|
||||||
|
VoxelEngineSrc
|
||||||
|
PUBLIC $<$<CXX_COMPILER_ID:MSVC>:
|
||||||
|
/utf-8
|
||||||
|
/MP
|
||||||
|
/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
|
||||||
|
/W4
|
||||||
|
/wd4244 # conversion from 'a' to 'T', possible loss of data
|
||||||
|
/wd4267 # conversion from 'size_t' to 'int', possible loss of data
|
||||||
|
/wd4245 # conversion from 'int' to 'const size_t', signed/unsigned
|
||||||
|
# mismatch
|
||||||
|
/wd4100 # unreferenced formal parameter
|
||||||
|
/wd4458 # declaration of 'var' hides class member
|
||||||
|
/wd4101 # 'var': unreferenced local variable
|
||||||
|
/wd4388 # 'token' : signed/unsigned mismatch
|
||||||
|
/wd4018 # '>': signed/unsigned mismatch
|
||||||
|
>
|
||||||
|
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
# additional warnings
|
||||||
|
-Wformat-nonliteral
|
||||||
|
-Wcast-align
|
||||||
|
-Wpointer-arith
|
||||||
|
-Wundef
|
||||||
|
-Wwrite-strings
|
||||||
|
-Wno-unused-parameter
|
||||||
|
-Wno-sign-compare
|
||||||
|
$<$<CONFIG:Debug>:-Og>
|
||||||
|
>)
|
||||||
|
|
||||||
|
target_link_options(
|
||||||
|
VoxelEngineSrc
|
||||||
|
PUBLIC
|
||||||
|
$<$<CXX_COMPILER_ID:GNU>:
|
||||||
|
-no-pie
|
||||||
|
>
|
||||||
|
# Need for static compilation on Windows with clang TODO: Make single build
|
||||||
|
# on Windows to avoid dependence on combinations of platforms and compilers
|
||||||
|
# and make it independent
|
||||||
|
$<$<PLATFORM_ID:Windows>:$<$<CXX_COMPILER_ID:Clang>:-static>>)
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "io/io.hpp"
|
#include "io/io.hpp"
|
||||||
#include "io/engine_paths.hpp"
|
#include "io/engine_paths.hpp"
|
||||||
#include "logic/scripting/scripting.hpp"
|
#include "logic/scripting/scripting.hpp"
|
||||||
|
#include "util/stringutil.hpp"
|
||||||
#include "world/generator/GeneratorDef.hpp"
|
#include "world/generator/GeneratorDef.hpp"
|
||||||
#include "world/generator/VoxelFragment.hpp"
|
#include "world/generator/VoxelFragment.hpp"
|
||||||
#include "debug/Logger.hpp"
|
#include "debug/Logger.hpp"
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
#include "Label.hpp"
|
#include "Label.hpp"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "assets/Assets.hpp"
|
||||||
#include "graphics/core/DrawContext.hpp"
|
#include "graphics/core/DrawContext.hpp"
|
||||||
#include "graphics/core/Batch2D.hpp"
|
#include "graphics/core/Batch2D.hpp"
|
||||||
#include "graphics/core/Font.hpp"
|
#include "graphics/core/Font.hpp"
|
||||||
#include "assets/Assets.hpp"
|
#include "graphics/ui/markdown.hpp"
|
||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
#include "../markdown.hpp"
|
|
||||||
|
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
#include "TextBox.hpp"
|
#include "TextBox.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "Label.hpp"
|
#include "Label.hpp"
|
||||||
#include "devtools/syntax_highlighting.hpp"
|
|
||||||
#include "graphics/core/DrawContext.hpp"
|
|
||||||
#include "graphics/core/Batch2D.hpp"
|
|
||||||
#include "graphics/core/Font.hpp"
|
|
||||||
#include "assets/Assets.hpp"
|
#include "assets/Assets.hpp"
|
||||||
|
#include "devtools/syntax_highlighting.hpp"
|
||||||
|
#include "graphics/core/Batch2D.hpp"
|
||||||
|
#include "graphics/core/DrawContext.hpp"
|
||||||
|
#include "graphics/core/Font.hpp"
|
||||||
|
#include "graphics/ui/markdown.hpp"
|
||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
#include "window/Events.hpp"
|
#include "window/Events.hpp"
|
||||||
#include "window/Window.hpp"
|
#include "window/Window.hpp"
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "typedefs.hpp"
|
|
||||||
#include "delegates.hpp"
|
#include "delegates.hpp"
|
||||||
|
#include "typedefs.hpp"
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template<class...Types>
|
template <class... Types>
|
||||||
class HandlersList {
|
class HandlersList {
|
||||||
int nextid = 1;
|
int nextid = 1;
|
||||||
std::unordered_map<int, std::function<bool(Types...)>> handlers;
|
std::unordered_map<int, std::function<bool(Types...)>> handlers;
|
||||||
@ -35,7 +35,7 @@ namespace util {
|
|||||||
int id = nextid++;
|
int id = nextid++;
|
||||||
handlers[id] = std::move(handler);
|
handlers[id] = std::move(handler);
|
||||||
order.push_back(id);
|
order.push_back(id);
|
||||||
return observer_handler(new int(id), [this](int* id) { //-V508
|
return observer_handler(new int(id), [this](int* id) { //-V508
|
||||||
std::lock_guard lock(mutex);
|
std::lock_guard lock(mutex);
|
||||||
handlers.erase(*id);
|
handlers.erase(*id);
|
||||||
order.erase(
|
order.erase(
|
||||||
@ -45,7 +45,7 @@ namespace util {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify(Types...args) {
|
void notify(Types... args) {
|
||||||
std::vector<int> orderCopy;
|
std::vector<int> orderCopy;
|
||||||
decltype(handlers) handlersCopy;
|
decltype(handlers) handlersCopy;
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include "content/Content.hpp"
|
#include "content/Content.hpp"
|
||||||
#include "maths/voxmaths.hpp"
|
#include "maths/voxmaths.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@ -1,26 +1,22 @@
|
|||||||
project(VoxelEngineTest)
|
project(VoxelEngineTest)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
|
||||||
|
|
||||||
find_package(GTest)
|
find_package(GTest)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
add_executable(VoxelEngineTest ${sources})
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME}
|
target_link_libraries(VoxelEngineTest PRIVATE VoxelEngineSrc GTest::gtest_main)
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
|
||||||
target_link_libraries(${PROJECT_NAME} VoxelEngineSrc GTest::gtest_main)
|
|
||||||
|
|
||||||
# HACK: copy res to test/ folder for fixing problem compatibility MultiConfig
|
# HACK: copy res to test/ folder for fixing problem compatibility MultiConfig
|
||||||
# and non MultiConfig builds. Delete in future and use only root res folder Also
|
# and non MultiConfig builds. Delete in future and use only root res folder Also
|
||||||
# this resolve problem with ctests, because it set cwd to
|
# this resolve problem with ctests, because it set cwd to
|
||||||
# CMAKE_CURRENT_BINARY_DIR
|
# ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${PROJECT_NAME}
|
TARGET VoxelEngineTest
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
||||||
${CMAKE_SOURCE_DIR}/res ${CMAKE_CURRENT_BINARY_DIR}/res)
|
${CMAKE_SOURCE_DIR}/res ${CMAKE_CURRENT_BINARY_DIR}/res)
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(${PROJECT_NAME})
|
gtest_discover_tests(VoxelEngineTest)
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
#include "coders/lua_parsing.hpp"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "coders/commons.hpp"
|
#include "coders/commons.hpp"
|
||||||
#include "coders/lua_parsing.hpp"
|
|
||||||
#include "io/io.hpp"
|
#include "io/io.hpp"
|
||||||
#include "io/devices/StdfsDevice.hpp"
|
#include "io/devices/StdfsDevice.hpp"
|
||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
|
|||||||
@ -1,42 +1,22 @@
|
|||||||
project(vctest)
|
project(vctest)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
add_executable(vctest ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
# Needed for header-only source util/ArgsReader.hpp
|
||||||
|
target_include_directories(vctest PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
target_compile_options(
|
||||||
|
vctest
|
||||||
|
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/W4>
|
||||||
|
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Wformat-nonliteral
|
||||||
|
-Wcast-align
|
||||||
|
-Wpointer-arith
|
||||||
|
-Wundef
|
||||||
|
-Wwrite-strings
|
||||||
|
-Wno-unused-parameter
|
||||||
|
>)
|
||||||
|
|
||||||
if(MSVC)
|
target_link_options(vctest PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
set(CMAKE_BUILD_TYPE
|
|
||||||
Release
|
|
||||||
CACHE STRING "Build type" FORCE)
|
|
||||||
endif()
|
|
||||||
if((CMAKE_BUILD_TYPE EQUAL "Release") OR (CMAKE_BUILD_TYPE EQUAL
|
|
||||||
"RelWithDebInfo"))
|
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY
|
|
||||||
"MultiThreaded$<$<CONFIG:Release>:Release>")
|
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /MT /O2)
|
|
||||||
else()
|
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
|
|
||||||
endif()
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
||||||
else()
|
|
||||||
target_compile_options(
|
|
||||||
${PROJECT_NAME}
|
|
||||||
PRIVATE -Wall
|
|
||||||
-Wextra
|
|
||||||
-Wformat-nonliteral
|
|
||||||
-Wcast-align
|
|
||||||
-Wpointer-arith
|
|
||||||
-Wundef
|
|
||||||
-Wwrite-strings
|
|
||||||
-Wno-unused-parameter)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_include_directories(
|
|
||||||
${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_DL_LIBS})
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user