From d63150487226f38561a567689b6fd88e1c9075e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Thu, 4 Jul 2024 13:01:43 +0200 Subject: [PATCH] Add CMake preset. --- .gitignore | 1 + CMakeLists.txt | 15 +-- CMakePresets.json | 117 ++++++++++++++++++ .../ports/asmjit}/asmjit.patch | 0 .../ports/asmjit}/portfile.cmake | 0 .../fb9f82c => cmake/ports/asmjit}/vcpkg.json | 0 src/shared/CMakeLists.txt | 1 - src/thooklib/CMakeLists.txt | 1 - src/tinjectlib/CMakeLists.txt | 1 - src/usvfs_dll/CMakeLists.txt | 1 - src/usvfs_helper/CMakeLists.txt | 1 - src/usvfs_proxy/CMakeLists.txt | 1 - test/shared_test/CMakeLists.txt | 1 - test/test_utils/CMakeLists.txt | 1 - test/thooklib_test/CMakeLists.txt | 1 - test/tinjectlib_test/CMakeLists.txt | 3 - test/tvfs_test/CMakeLists.txt | 1 - test/usvfs_test_runner/CMakeLists.txt | 3 - vcpkg-configuration.json | 27 ---- vcpkg-registry/versions/a-/asmjit.json | 8 -- vcpkg-registry/versions/baseline.json | 8 -- vcpkg-triplets/x64-windows.cmake | 3 - vcpkg-triplets/x86-windows.cmake | 3 - vcpkg.json | 1 + 24 files changed, 120 insertions(+), 79 deletions(-) create mode 100644 CMakePresets.json rename {vcpkg-registry/ports/asmjit/fb9f82c => cmake/ports/asmjit}/asmjit.patch (100%) rename {vcpkg-registry/ports/asmjit/fb9f82c => cmake/ports/asmjit}/portfile.cmake (100%) rename {vcpkg-registry/ports/asmjit/fb9f82c => cmake/ports/asmjit}/vcpkg.json (100%) delete mode 100644 vcpkg-configuration.json delete mode 100644 vcpkg-registry/versions/a-/asmjit.json delete mode 100644 vcpkg-registry/versions/baseline.json delete mode 100644 vcpkg-triplets/x64-windows.cmake delete mode 100644 vcpkg-triplets/x86-windows.cmake diff --git a/.gitignore b/.gitignore index 20752e8..3d8da0b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ /vsbuild/ReleaseTest /vsbuild/Debug /vsbuild/DebugTest +CMakeUserPresets.json # test "side effects" /test/temp diff --git a/CMakeLists.txt b/CMakeLists.txt index b2fc483..7a03764 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,5 @@ cmake_minimum_required(VERSION 3.16) -if (BUILD_USVFS_TESTS) - list(APPEND VCPKG_MANIFEST_FEATURES "testing") -endif() - project(usvfs) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -18,15 +14,6 @@ else() set(ARCH_POSTFIX _x64) endif() -#! usvfs_configure_target -# -# common configuration for all targets -# -function(usvfs_configure_target TARGET) - # TODO: wrap this in if() block - target_compile_options(${TARGET} PRIVATE "/MP") -endfunction() - add_subdirectory(src/shared) add_subdirectory(src/thooklib) @@ -36,7 +23,7 @@ add_subdirectory(src/usvfs_helper) add_subdirectory(src/usvfs_dll) add_subdirectory(src/usvfs_proxy) -if (BUILD_USVFS_TESTS) +if (BUILD_TESTING) enable_testing() set(USVFS_TEST_BINDIR ${CMAKE_CURRENT_LIST_DIR}/test/bin) add_subdirectory(test) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..0829c08 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,117 @@ +{ + "configurePresets": [ + { + "cacheVariables": { + "BUILD_TESTING": { + "type": "BOOL", + "value": "ON" + } + }, + "errors": { + "deprecated": true + }, + "hidden": true, + "name": "cmake-dev", + "warnings": { + "deprecated": true, + "dev": true + } + }, + { + "cacheVariables": { + "VCPKG_MANIFEST_NO_DEFAULT_FEATURES": { + "type": "BOOL", + "value": "ON" + }, + "VCPKG_OVERLAY_PORTS": { + "type": "STRING", + "value": "${sourceDir}/cmake/ports" + } + }, + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "hidden": true, + "name": "vcpkg" + }, + { + "cacheVariables": { + "VCPKG_MANIFEST_FEATURES": { + "type": "STRING", + "value": "testing" + } + }, + "hidden": true, + "inherits": [ + "vcpkg" + ], + "name": "vcpkg-dev" + }, + { + "binaryDir": "${sourceDir}/cbuild64", + "architecture": { + "strategy": "set", + "value": "x64" + }, + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "x64-windows-static-md" + } + }, + "hidden": true, + "name": "windows-x64" + }, + { + "binaryDir": "${sourceDir}/cbuild32", + "architecture": { + "strategy": "set", + "value": "Win32" + }, + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "x86-windows-static-md" + } + }, + "hidden": true, + "name": "windows-x86" + }, + { + "cacheVariables": { + "CMAKE_CXX_FLAGS": "/EHsc /MP /W4" + }, + "generator": "Visual Studio 17 2022", + "inherits": [ + "cmake-dev", + "vcpkg-dev" + ], + "hidden": true, + "name": "vs2022-windows", + "toolset": "v143" + }, + { + "inherits": [ + "vs2022-windows", + "windows-x64" + ], + "name": "vs2022-windows-x64" + }, + { + "inherits": [ + "vs2022-windows", + "windows-x86" + ], + "name": "vs2022-windows-x86" + } + ], + "buildPresets": [ + { + "name": "vs2022-windows-x64", + "configurePreset": "vs2022-windows-x64" + }, + { + "name": "vs2022-windows-x86", + "configurePreset": "vs2022-windows-x86" + } + ], + "version": 3 +} diff --git a/vcpkg-registry/ports/asmjit/fb9f82c/asmjit.patch b/cmake/ports/asmjit/asmjit.patch similarity index 100% rename from vcpkg-registry/ports/asmjit/fb9f82c/asmjit.patch rename to cmake/ports/asmjit/asmjit.patch diff --git a/vcpkg-registry/ports/asmjit/fb9f82c/portfile.cmake b/cmake/ports/asmjit/portfile.cmake similarity index 100% rename from vcpkg-registry/ports/asmjit/fb9f82c/portfile.cmake rename to cmake/ports/asmjit/portfile.cmake diff --git a/vcpkg-registry/ports/asmjit/fb9f82c/vcpkg.json b/cmake/ports/asmjit/vcpkg.json similarity index 100% rename from vcpkg-registry/ports/asmjit/fb9f82c/vcpkg.json rename to cmake/ports/asmjit/vcpkg.json diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index 280befa..c62a0d4 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -7,7 +7,6 @@ file(GLOB sources "*.cpp" "*.h") source_group("" FILES ${sources}) add_library(shared STATIC ${sources}) -usvfs_configure_target(shared) target_link_libraries(shared PUBLIC Boost::algorithm Boost::interprocess comsuppw diff --git a/src/thooklib/CMakeLists.txt b/src/thooklib/CMakeLists.txt index 84d1e50..48426db 100644 --- a/src/thooklib/CMakeLists.txt +++ b/src/thooklib/CMakeLists.txt @@ -8,7 +8,6 @@ file(GLOB sources CONFIGURE_DEPENDS "*.cpp" "*.h") source_group("" FILES ${sources}) add_library(thooklib STATIC ${sources}) -usvfs_configure_target(thooklib) target_link_libraries(thooklib PRIVATE shared asmjit::asmjit ${LIBUDIS86_LIBRARY} spdlog::spdlog_header_only) target_include_directories(thooklib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(thooklib PROPERTIES FOLDER injection) diff --git a/src/tinjectlib/CMakeLists.txt b/src/tinjectlib/CMakeLists.txt index 43ef79e..096608e 100644 --- a/src/tinjectlib/CMakeLists.txt +++ b/src/tinjectlib/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.16) find_package(asmjit CONFIG REQUIRED) add_library(tinjectlib STATIC asmjit_sane.h injectlib.cpp injectlib.h) -usvfs_configure_target(tinjectlib) target_link_libraries(tinjectlib PRIVATE shared asmjit::asmjit) target_include_directories(tinjectlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(tinjectlib PROPERTIES FOLDER injection) diff --git a/src/usvfs_dll/CMakeLists.txt b/src/usvfs_dll/CMakeLists.txt index 8a0ff4f..624874f 100644 --- a/src/usvfs_dll/CMakeLists.txt +++ b/src/usvfs_dll/CMakeLists.txt @@ -29,7 +29,6 @@ target_sources(usvfs_dll ${PROJECT_SOURCE_DIR}/include/usvfs/usvfs.h ${PROJECT_SOURCE_DIR}/include/usvfs/usvfsparameters.h ) -usvfs_configure_target(usvfs_dll) target_link_libraries(usvfs_dll PRIVATE shared thooklib usvfs_helper Boost::thread spdlog::spdlog_header_only diff --git a/src/usvfs_helper/CMakeLists.txt b/src/usvfs_helper/CMakeLists.txt index 28a43f2..5e083d9 100644 --- a/src/usvfs_helper/CMakeLists.txt +++ b/src/usvfs_helper/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.16) add_library(usvfs_helper STATIC inject.h inject.cpp) -usvfs_configure_target(usvfs_helper) target_link_libraries(usvfs_helper PUBLIC shared PRIVATE tinjectlib) target_include_directories(usvfs_helper PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(usvfs_helper PROPERTIES FOLDER injection) diff --git a/src/usvfs_proxy/CMakeLists.txt b/src/usvfs_proxy/CMakeLists.txt index d7abf22..ffa9058 100644 --- a/src/usvfs_proxy/CMakeLists.txt +++ b/src/usvfs_proxy/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.16) find_package(Boost CONFIG REQUIRED COMPONENTS filesystem) add_executable(usvfs_proxy main.cpp version.rc) -usvfs_configure_target(usvfs_proxy main.cpp) target_link_libraries(usvfs_proxy PRIVATE usvfs_dll shared usvfs_helper) set_target_properties(usvfs_proxy PROPERTIES diff --git a/test/shared_test/CMakeLists.txt b/test/shared_test/CMakeLists.txt index 285c413..c5a42ea 100644 --- a/test/shared_test/CMakeLists.txt +++ b/test/shared_test/CMakeLists.txt @@ -3,6 +3,5 @@ cmake_minimum_required(VERSION 3.16) find_package(GTest CONFIG REQUIRED) add_executable(shared_test main.cpp) -usvfs_configure_target(shared_test) usvfs_set_test_properties(shared_test) target_link_libraries(shared_test PRIVATE test_utils GTest::gtest GTest::gtest_main) diff --git a/test/test_utils/CMakeLists.txt b/test/test_utils/CMakeLists.txt index b88b2b7..cdb86d9 100644 --- a/test/test_utils/CMakeLists.txt +++ b/test/test_utils/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.16) find_package(GTest CONFIG REQUIRED) add_library(test_utils STATIC test_helpers.cpp test_helpers.h) -usvfs_configure_target(test_utils) set_target_properties(test_utils PROPERTIES FOLDER tests) target_link_libraries(test_utils PUBLIC shared) target_include_directories(test_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/test/thooklib_test/CMakeLists.txt b/test/thooklib_test/CMakeLists.txt index 7b93c92..cca9e10 100644 --- a/test/thooklib_test/CMakeLists.txt +++ b/test/thooklib_test/CMakeLists.txt @@ -5,7 +5,6 @@ find_package(Boost CONFIG REQUIRED COMPONENTS thread) # not sure why there is a test_hooks.cpp here? add_executable(thooklib_test main.cpp) -usvfs_configure_target(thooklib_test) usvfs_set_test_properties(thooklib_test) target_link_libraries(thooklib_test PRIVATE test_utils shared thooklib Boost::thread diff --git a/test/tinjectlib_test/CMakeLists.txt b/test/tinjectlib_test/CMakeLists.txt index 586127e..9bd3f7b 100644 --- a/test/tinjectlib_test/CMakeLists.txt +++ b/test/tinjectlib_test/CMakeLists.txt @@ -4,16 +4,13 @@ find_package(GTest CONFIG REQUIRED) # binary and binary injected add_executable(testinject_bin testinject_bin/main.cpp) -usvfs_configure_target(testinject_bin) usvfs_set_test_properties(testinject_bin FOLDER tinjectlib) add_library(testinject_dll SHARED testinject_dll/main.cpp testinject_dll/main.h) -usvfs_configure_target(testinject_dll) usvfs_set_test_properties(testinject_dll FOLDER tinjectlib) # actual test executable add_executable(tinjectlib_test main.cpp) -usvfs_configure_target(tinjectlib_test) usvfs_set_test_properties(tinjectlib_test FOLDER tinjectlib) target_link_libraries(tinjectlib_test PRIVATE tinjectlib shared GTest::gtest GTest::gtest_main) add_dependencies(tinjectlib_test testinject_bin testinject_dll) diff --git a/test/tvfs_test/CMakeLists.txt b/test/tvfs_test/CMakeLists.txt index 2e94c7f..76a5306 100644 --- a/test/tvfs_test/CMakeLists.txt +++ b/test/tvfs_test/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.16) find_package(GTest CONFIG REQUIRED) add_executable(tvfs_test main.cpp) -usvfs_configure_target(tvfs_test) usvfs_set_test_properties(tvfs_test) target_link_libraries(tvfs_test PRIVATE test_utils usvfs_helper GTest::gtest GTest::gtest_main) usvfs_target_link_usvfs(tvfs_test) diff --git a/test/usvfs_test_runner/CMakeLists.txt b/test/usvfs_test_runner/CMakeLists.txt index 38d60d5..a0a7ca9 100644 --- a/test/usvfs_test_runner/CMakeLists.txt +++ b/test/usvfs_test_runner/CMakeLists.txt @@ -13,7 +13,6 @@ add_executable(test_file_operations test_file_operations/test_w32api.cpp test_file_operations/test_w32api.h ) -usvfs_configure_target(test_file_operations) usvfs_set_test_properties(test_file_operations FOLDER usvfs_test_runner) target_link_libraries(test_file_operations PRIVATE test_utils ntdll) @@ -24,14 +23,12 @@ add_executable(usvfs_test usvfs_test/usvfs_test_base.h usvfs_test/usvfs_test.cpp ) -usvfs_configure_target(usvfs_test) usvfs_set_test_properties(usvfs_test FOLDER usvfs_test_runner) usvfs_target_link_usvfs(usvfs_test) target_link_libraries(usvfs_test PRIVATE test_utils) # actual test executable add_executable(usvfs_test_runner usvfs_test_runner.cpp) -usvfs_configure_target(usvfs_test_runner) usvfs_set_test_properties(usvfs_test_runner FOLDER usvfs_test_runner) target_link_libraries(usvfs_test_runner PRIVATE test_utils GTest::gtest GTest::gtest_main) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json deleted file mode 100644 index 50bc428..0000000 --- a/vcpkg-configuration.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "default-registry": { - "kind": "git", - "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7" - }, - "registries": [ - { - "kind": "git", - "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7", - "packages": [ - "boost*", - "boost-*" - ] - }, - { - "kind": "filesystem", - "baseline": "asmjit-fb9f82c", - "path": "./vcpkg-registry", - "packages": [ "asmjit" ] - } - ], - "overlay-triplets": [ - "./vcpkg-triplets" - ] -} diff --git a/vcpkg-registry/versions/a-/asmjit.json b/vcpkg-registry/versions/a-/asmjit.json deleted file mode 100644 index 7dbaf92..0000000 --- a/vcpkg-registry/versions/a-/asmjit.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "versions": [ - { - "version-string": "fb9f82c", - "path": "$/ports/asmjit/fb9f82c" - } - ] -} diff --git a/vcpkg-registry/versions/baseline.json b/vcpkg-registry/versions/baseline.json deleted file mode 100644 index f5cd36a..0000000 --- a/vcpkg-registry/versions/baseline.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "asmjit-fb9f82c": { - "asmjit": { - "baseline": "fb9f82c", - "port-version": 0 - } - } -} diff --git a/vcpkg-triplets/x64-windows.cmake b/vcpkg-triplets/x64-windows.cmake deleted file mode 100644 index 63d6cde..0000000 --- a/vcpkg-triplets/x64-windows.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(VCPKG_TARGET_ARCHITECTURE x64) -set(VCPKG_CRT_LINKAGE dynamic) -set(VCPKG_LIBRARY_LINKAGE static) diff --git a/vcpkg-triplets/x86-windows.cmake b/vcpkg-triplets/x86-windows.cmake deleted file mode 100644 index 2496b16..0000000 --- a/vcpkg-triplets/x86-windows.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(VCPKG_TARGET_ARCHITECTURE x86) -set(VCPKG_CRT_LINKAGE dynamic) -set(VCPKG_LIBRARY_LINKAGE static) diff --git a/vcpkg.json b/vcpkg.json index ac154a8..ba611cc 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -18,6 +18,7 @@ "boost-thread", "boost-predef" ], + "builtin-baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7", "features": { "testing": { "description": "Build USVFS tests.",