From 81089c6d7e552f1534cdee14d56bf7df17915dc7 Mon Sep 17 00:00:00 2001 From: Angad <66992519+ThirdEyeSqueegee@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:47:11 -0700 Subject: [PATCH] fix: add subfolders to build scripts, make test config build only test target --- CommonLibSF/CMakeLists.txt | 28 ++++++++++----------- CommonLibSF/include/SFSE/Impl/PCH.h | 1 + scripts/build-debug-clang-cl-cpm.bat | 5 ++-- scripts/build-debug-clang-cl-vcpkg.bat | 5 ++-- scripts/build-debug-msvc-cpm-test.bat | 3 +++ scripts/build-debug-msvc-cpm.bat | 5 ++-- scripts/build-debug-msvc-vcpkg.bat | 5 ++-- scripts/build-release-clang-cl-cpm-test.bat | 5 ++-- scripts/build-release-clang-cl-cpm.bat | 5 ++-- scripts/build-release-clang-cl-vcpkg.bat | 5 ++-- scripts/build-release-msvc-cpm-test.bat | 5 ++-- scripts/build-release-msvc-cpm.bat | 5 ++-- scripts/build-release-msvc-vcpkg.bat | 5 ++-- scripts/make-sln-clang-cl-cpm.bat | 3 +-- scripts/make-sln-clang-cl-vcpkg.bat | 3 +-- scripts/make-sln-msvc-cpm.bat | 3 +-- scripts/make-sln-msvc-vcpkg.bat | 3 +-- 17 files changed, 41 insertions(+), 53 deletions(-) create mode 100644 scripts/build-debug-msvc-cpm-test.bat diff --git a/CommonLibSF/CMakeLists.txt b/CommonLibSF/CMakeLists.txt index 7e02b872..c167ff91 100644 --- a/CommonLibSF/CMakeLists.txt +++ b/CommonLibSF/CMakeLists.txt @@ -59,15 +59,6 @@ source_group( FILES ${SOURCES} ) -add_library( - ${PROJECT_NAME} - STATIC - ${SOURCES} - .clang-format -) - -add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - function (configure_target TARGET_NAME) target_compile_definitions( ${TARGET_NAME} @@ -144,14 +135,14 @@ function (configure_target TARGET_NAME) else() CPMAddPackage("gh:herumi/xbyak@6.73") endif() - + target_link_libraries( ${TARGET_NAME} PUBLIC xbyak::xbyak ) endif() - + target_precompile_headers( ${TARGET_NAME} PRIVATE @@ -159,9 +150,7 @@ function (configure_target TARGET_NAME) ) endfunction() -configure_target(${PROJECT_NAME}) - -if (SFSE_BUILD_TESTS) +if(SFSE_BUILD_TESTS) # add a custom library target that just builds test.cpp add_library( ${PROJECT_NAME}-test @@ -171,9 +160,18 @@ if (SFSE_BUILD_TESTS) ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp ) configure_target(${PROJECT_NAME}-test) + set(PROJECT_NAME ${PROJECT_NAME}-test) +else() + add_library( + ${PROJECT_NAME} + STATIC + ${SOURCES} + .clang-format + ) + add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + configure_target(${PROJECT_NAME}) endif() - if(USING_VCPKG) install( TARGETS ${PROJECT_NAME} diff --git a/CommonLibSF/include/SFSE/Impl/PCH.h b/CommonLibSF/include/SFSE/Impl/PCH.h index 80dcf342..c994143d 100644 --- a/CommonLibSF/include/SFSE/Impl/PCH.h +++ b/CommonLibSF/include/SFSE/Impl/PCH.h @@ -760,4 +760,5 @@ namespace REL #include "RE/F/FormTypes.h" #include "RE/M/msvc.h" + #undef cdecl // Workaround for Clang. diff --git a/scripts/build-debug-clang-cl-cpm.bat b/scripts/build-debug-clang-cl-cpm.bat index c7966e40..5bdd56b7 100644 --- a/scripts/build-debug-clang-cl-cpm.bat +++ b/scripts/build-debug-clang-cl-cpm.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-ninja-cpm -cmake --build "%~dp0/../build" --config Debug +cmake -B "%~dp0/../build/build-debug-clang-cl-ninja-cpm" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-ninja-cpm +cmake --build "%~dp0/../build/build-debug-clang-cl-ninja-cpm" --config Debug diff --git a/scripts/build-debug-clang-cl-vcpkg.bat b/scripts/build-debug-clang-cl-vcpkg.bat index 8bc2ea54..b96f9be6 100644 --- a/scripts/build-debug-clang-cl-vcpkg.bat +++ b/scripts/build-debug-clang-cl-vcpkg.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-ninja-vcpkg -cmake --build "%~dp0/../build" --config Debug +cmake -B "%~dp0/../build/build-debug-clang-cl-ninja-vcpkg" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-ninja-vcpkg +cmake --build "%~dp0/../build/build-debug-clang-cl-ninja-vcpkg" --config Debug diff --git a/scripts/build-debug-msvc-cpm-test.bat b/scripts/build-debug-msvc-cpm-test.bat new file mode 100644 index 00000000..6081b196 --- /dev/null +++ b/scripts/build-debug-msvc-cpm-test.bat @@ -0,0 +1,3 @@ +echo off +cmake -B "%~dp0/../build/build-debug-msvc-ninja-cpm-test" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-ninja-cpm -DSFSE_BUILD_TESTS=true +cmake --build "%~dp0/../build/build-debug-msvc-ninja-cpm-test" --config Debug diff --git a/scripts/build-debug-msvc-cpm.bat b/scripts/build-debug-msvc-cpm.bat index 8e12363f..7237c539 100644 --- a/scripts/build-debug-msvc-cpm.bat +++ b/scripts/build-debug-msvc-cpm.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-ninja-cpm -cmake --build "%~dp0/../build" --config Debug +cmake -B "%~dp0/../build/build-debug-msvc-ninja-cpm" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-ninja-cpm +cmake --build "%~dp0/../build/build-debug-msvc-ninja-cpm" --config Debug diff --git a/scripts/build-debug-msvc-vcpkg.bat b/scripts/build-debug-msvc-vcpkg.bat index 460a8233..ba607a37 100644 --- a/scripts/build-debug-msvc-vcpkg.bat +++ b/scripts/build-debug-msvc-vcpkg.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-ninja-vcpkg -cmake --build "%~dp0/../build" --config Debug +cmake -B "%~dp0/../build/build-debug-msvc-ninja-vcpkg" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-ninja-vcpkg +cmake --build "%~dp0/../build/build-debug-msvc-ninja-vcpkg" --config Debug diff --git a/scripts/build-release-clang-cl-cpm-test.bat b/scripts/build-release-clang-cl-cpm-test.bat index ccddbde5..7110f1f2 100644 --- a/scripts/build-release-clang-cl-cpm-test.bat +++ b/scripts/build-release-clang-cl-cpm-test.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-release-clang-cl-ninja-cpm -DSFSE_BUILD_TESTS=true -cmake --build "%~dp0/../build" --config Release +cmake -B "%~dp0/../build/build-release-clang-cl-ninja-cpm-test" -S "%~dp0/../CommonLibSF" --preset=build-release-clang-cl-ninja-cpm -DSFSE_BUILD_TESTS=true +cmake --build "%~dp0/../build/build-release-clang-cl-ninja-cpm-test" --config Release diff --git a/scripts/build-release-clang-cl-cpm.bat b/scripts/build-release-clang-cl-cpm.bat index af658e05..9bf7aa32 100644 --- a/scripts/build-release-clang-cl-cpm.bat +++ b/scripts/build-release-clang-cl-cpm.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-release-clang-cl-ninja-cpm -cmake --build "%~dp0/../build" --config Release +cmake -B "%~dp0/../build/build-release-clang-cl-ninja-cpm" -S "%~dp0/../CommonLibSF" --preset=build-release-clang-cl-ninja-cpm +cmake --build "%~dp0/../build/build-release-clang-cl-ninja-cpm" --config Release diff --git a/scripts/build-release-clang-cl-vcpkg.bat b/scripts/build-release-clang-cl-vcpkg.bat index 93d373d3..a975c55d 100644 --- a/scripts/build-release-clang-cl-vcpkg.bat +++ b/scripts/build-release-clang-cl-vcpkg.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-release-clang-cl-ninja-vcpkg -cmake --build "%~dp0/../build" --config Release +cmake -B "%~dp0/../build/build-release-clang-cl-ninja-vcpkg" -S "%~dp0/../CommonLibSF" --preset=build-release-clang-cl-ninja-vcpkg +cmake --build "%~dp0/../build/build-release-clang-cl-ninja-vcpkg" --config Release diff --git a/scripts/build-release-msvc-cpm-test.bat b/scripts/build-release-msvc-cpm-test.bat index 9a50884d..8991981b 100644 --- a/scripts/build-release-msvc-cpm-test.bat +++ b/scripts/build-release-msvc-cpm-test.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-release-msvc-ninja-cpm -DSFSE_BUILD_TESTS=true -cmake --build "%~dp0/../build" --config Release +cmake -B "%~dp0/../build/build-release-msvc-ninja-cpm-test" -S "%~dp0/../CommonLibSF" --preset=build-release-msvc-ninja-cpm -DSFSE_BUILD_TESTS=true +cmake --build "%~dp0/../build/build-release-msvc-ninja-cpm-test" --config Release diff --git a/scripts/build-release-msvc-cpm.bat b/scripts/build-release-msvc-cpm.bat index 502a3663..30426e5a 100644 --- a/scripts/build-release-msvc-cpm.bat +++ b/scripts/build-release-msvc-cpm.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-release-msvc-ninja-cpm -cmake --build "%~dp0/../build" --config Release +cmake -B "%~dp0/../build/build-release-msvc-ninja-cpm" -S "%~dp0/../CommonLibSF" --preset=build-release-msvc-ninja-cpm +cmake --build "%~dp0/../build/build-release-msvc-ninja-cpm" --config Release diff --git a/scripts/build-release-msvc-vcpkg.bat b/scripts/build-release-msvc-vcpkg.bat index a35c8a7e..77b4db56 100644 --- a/scripts/build-release-msvc-vcpkg.bat +++ b/scripts/build-release-msvc-vcpkg.bat @@ -1,4 +1,3 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-release-msvc-ninja-vcpkg -cmake --build "%~dp0/../build" --config Release +cmake -B "%~dp0/../build/build-release-msvc-ninja-vcpkg" -S "%~dp0/../CommonLibSF" --preset=build-release-msvc-ninja-vcpkg +cmake --build "%~dp0/../build/build-release-msvc-ninja-vcpkg" --config Release diff --git a/scripts/make-sln-clang-cl-cpm.bat b/scripts/make-sln-clang-cl-cpm.bat index f3054fee..0a3a01ee 100644 --- a/scripts/make-sln-clang-cl-cpm.bat +++ b/scripts/make-sln-clang-cl-cpm.bat @@ -1,3 +1,2 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-msvc-cpm +cmake -B "%~dp0/../build/build-debug-clang-cl-msvc-cpm" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-msvc-cpm diff --git a/scripts/make-sln-clang-cl-vcpkg.bat b/scripts/make-sln-clang-cl-vcpkg.bat index f3befa22..a540eda3 100644 --- a/scripts/make-sln-clang-cl-vcpkg.bat +++ b/scripts/make-sln-clang-cl-vcpkg.bat @@ -1,3 +1,2 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-msvc-vcpkg +cmake -B "%~dp0/../build/build-debug-clang-cl-msvc-vcpkg" -S "%~dp0/../CommonLibSF" --preset=build-debug-clang-cl-msvc-vcpkg diff --git a/scripts/make-sln-msvc-cpm.bat b/scripts/make-sln-msvc-cpm.bat index b3812d39..5926617f 100644 --- a/scripts/make-sln-msvc-cpm.bat +++ b/scripts/make-sln-msvc-cpm.bat @@ -1,3 +1,2 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-msvc-cpm +cmake -B "%~dp0/../build/build-debug-msvc-msvc-cpm" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-msvc-cpm diff --git a/scripts/make-sln-msvc-vcpkg.bat b/scripts/make-sln-msvc-vcpkg.bat index 5b14538a..479fbc9c 100644 --- a/scripts/make-sln-msvc-vcpkg.bat +++ b/scripts/make-sln-msvc-vcpkg.bat @@ -1,3 +1,2 @@ echo off -rd /s /q "%~dp0/../build" -cmake -B "%~dp0/../build" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-msvc-vcpkg +cmake -B "%~dp0/../build/build-debug-msvc-msvc-vcpkg" -S "%~dp0/../CommonLibSF" --preset=build-debug-msvc-msvc-vcpkg