From 2565b1f58f1c2cc3b23bca0e925d9145829c95c6 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Sat, 14 Jan 2023 01:37:49 -0500 Subject: [PATCH] Generalize basepath search logic for single-config dev builds on linux/macOS when using make or ninja --- neo/CMakeLists.txt | 8 +++++++- neo/cmake-macos-release.sh | 2 +- neo/cmake-macos-retail.sh | 2 +- neo/sys/posix/posix_main.cpp | 6 +++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index e13a4df2..15beeb6c 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -94,10 +94,16 @@ if(UNIX) set(USE_VULKAN ON) # SRS - Disable precompiled headers when cross-compiling on OSX, e.g. when creating universal binaries - if((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64" ) OR + if((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64" ) OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")) set(USE_PRECOMPILED_HEADERS OFF) endif() + + # SRS - For single-config dev builds, define NO_MULTI_CONFIG to search for basepath up 1 dir level vs 2 + if((CMAKE_GENERATOR MATCHES "Unix Makefiles") OR + (CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_GENERATOR MATCHES "Multi-Config")) + add_definitions(-DNO_MULTI_CONFIG) + endif() endif() if(COMPILE_COMMANDS) diff --git a/neo/cmake-macos-release.sh b/neo/cmake-macos-release.sh index 450a451a..e9064c69 100755 --- a/neo/cmake-macos-release.sh +++ b/neo/cmake-macos-release.sh @@ -3,4 +3,4 @@ rm -rf build mkdir build cd build # change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET= to match supported runtime targets -cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -DNO_MULTI_CONFIG" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-macos-retail.sh b/neo/cmake-macos-retail.sh index 2999f229..47844789 100755 --- a/neo/cmake-macos-retail.sh +++ b/neo/cmake-macos-retail.sh @@ -3,4 +3,4 @@ rm -rf build mkdir build cd build # change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET= to match supported runtime targets -cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -DNO_MULTI_CONFIG -DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/sys/posix/posix_main.cpp b/neo/sys/posix/posix_main.cpp index d05e1f3a..72c80336 100644 --- a/neo/sys/posix/posix_main.cpp +++ b/neo/sys/posix/posix_main.cpp @@ -473,9 +473,9 @@ const char* Sys_DefaultBasePath() #endif // SRS - Check for linux/macOS build path (directory structure with build dir and possible config suffix) basepath = exepath; - basepath.StripFilename(); // up 1st dir level for linux and macOS single-config makefile builds -#if defined(__APPLE__) && !defined( NO_MULTI_CONFIG ) - basepath.StripFilename(); // up 2nd dir level for macOS Xcode builds with Debug/Release/etc config suffix + basepath.StripFilename(); // up 1st dir level for single-config dev builds +#if !defined( NO_MULTI_CONFIG ) + basepath.StripFilename(); // up 2nd dir level for multi-config dev builds with Debug/Release/etc suffix #endif testbase = basepath; testbase += "/";