Skip to content

Commit

Permalink
Add CMake preset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 4, 2024
1 parent 3b9420f commit d631504
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/vsbuild/ReleaseTest
/vsbuild/Debug
/vsbuild/DebugTest
CMakeUserPresets.json

# test "side effects"
/test/temp
Expand Down
15 changes: 1 addition & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
117 changes: 117 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/thooklib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/tinjectlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion src/usvfs_dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/usvfs_helper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion src/usvfs_proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/shared_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion test/test_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/thooklib_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions test/tinjectlib_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion test/tvfs_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions test/usvfs_test_runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
27 changes: 0 additions & 27 deletions vcpkg-configuration.json

This file was deleted.

8 changes: 0 additions & 8 deletions vcpkg-registry/versions/a-/asmjit.json

This file was deleted.

8 changes: 0 additions & 8 deletions vcpkg-registry/versions/baseline.json

This file was deleted.

3 changes: 0 additions & 3 deletions vcpkg-triplets/x64-windows.cmake

This file was deleted.

3 changes: 0 additions & 3 deletions vcpkg-triplets/x86-windows.cmake

This file was deleted.

1 change: 1 addition & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"boost-thread",
"boost-predef"
],
"builtin-baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7",
"features": {
"testing": {
"description": "Build USVFS tests.",
Expand Down

0 comments on commit d631504

Please sign in to comment.