From 7fd019db43db8a7c4ae01c87ae803f651560455c Mon Sep 17 00:00:00 2001 From: Stepanov Igor Date: Thu, 9 Jan 2025 18:44:14 +0300 Subject: [PATCH] Add comment and try fix Windows compilation --- CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6c7e4fb7..e29fe9b1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(VOXELENGINE_BUILD_APPDIR "" OFF) option(VOXELENGINE_BUILD_TESTS "" OFF) -add_subdirectory(src) -add_executable(VoxelEngine src/main.cpp) - +# 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") # We use two types linking: for clang build is static (vcpkg triplet # x64-windows-static) and for msvc build is dynamic linking (vcpkg triplet @@ -19,11 +19,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(VCPKG_TARGET_TRIPLET MATCHES "static") # Need for MSVC clang set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - # Need for any clang - target_link_options(VoxelEngine PRIVATE $<$:-static>) endif() endif() +add_subdirectory(src) +add_executable(VoxelEngine src/main.cpp) + if(VOXELENGINE_BUILD_APPDIR) include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake) endif() @@ -46,6 +47,13 @@ else() -Wwrite-strings -Wno-unused-parameter $<$:-Og>) + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + # 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 + target_link_options(VoxelEngine PRIVATE + $<$:-static>) + endif() endif() target_link_options(VoxelEngine PRIVATE $<$:-no-pie