@@ -34,6 +34,7 @@ set (FEXCORE_PROFILER_BACKEND "gpuvis" CACHE STRING "Set which backend to use fo
3434option (ENABLE_GLIBC_ALLOCATOR_HOOK_FAULT "Enables glibc memory allocation hooking with fault for CI testing" )
3535option (USE_PDB_DEBUGINFO "Builds debug info in PDB format" FALSE )
3636option (BUILD_STEAM_SUPPORT "Builds FEX for integration into Steam" FALSE )
37+ option (USE_CPM "Fetch externals with CPM instead of submodules" FALSE )
3738
3839set (X86_32_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR} /Data/CMake/toolchain_x86_32.cmake" CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting i686" )
3940set (X86_64_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR} /Data/CMake/toolchain_x86_64.cmake" CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting x86_64" )
@@ -69,6 +70,15 @@ if (BUILD_STEAM_SUPPORT)
6970 add_definitions (-DFEX_STEAM_SUPPORT=1)
7071endif ()
7172
73+ if (USE_CPM)
74+ list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} /CMakeModules/)
75+ set (CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR} /.cache /cpm)
76+ set (CPM_USE_LOCAL_PACKAGES ON )
77+
78+ include (CPM)
79+ include (FEXCPMWrapper)
80+ endif ()
81+
7282if (ENABLE_FEXCORE_PROFILER)
7383 add_definitions (-DENABLE_FEXCORE_PROFILER=1)
7484 string (TOUPPER "${FEXCORE_PROFILER_BACKEND} " FEXCORE_PROFILER_BACKEND)
@@ -136,7 +146,6 @@ if (ENABLE_GDB_SYMBOLS)
136146 add_definitions (-DGDB_SYMBOLS_ENABLED=1)
137147endif ()
138148
139-
140149set (CMAKE_CXX_STANDARD 20)
141150set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
142151set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /Bin)
@@ -272,28 +281,19 @@ if (ENABLE_COVERAGE)
272281 link_libraries (-fprofile-instr-generate -fcoverage-mapping)
273282endif ()
274283
275- if (ENABLE_JEMALLOC_GLIBC_ALLOC)
276- # The glibc jemalloc subproject which hooks the glibc allocator.
277- # Required for thunks to work.
278- # All host native libraries will use this allocator, while *most* other FEX internal allocations will use the other jemalloc allocator.
279- add_subdirectory (External/jemalloc_glibc/)
280- elseif (NOT MINGW_BUILD)
281- message (STATUS
282- " jemalloc glibc allocator disabled!\n "
283- " This is not a recommended configuration!\n "
284- " This will very explicitly break thunk execution!\n "
285- " Use at your own risk!" )
284+ add_subdirectory (External)
285+ if (USE_CPM)
286+ if (BUILD_TESTING)
287+ find_package (Catch2 3 REQUIRED)
288+ endif ()
289+
290+ if (BUILD_THUNKS)
291+ find_package (Vulkan-Headers REQUIRED)
292+ endif ()
286293endif ()
287294
288- if (ENABLE_JEMALLOC)
289- # The jemalloc subproject that all FEXCore fextl objects allocate through.
290- add_subdirectory (External/jemalloc/)
291- elseif (NOT MINGW_BUILD)
292- message (STATUS
293- " jemalloc disabled!\n "
294- " This is not a recommended configuration!\n "
295- " This will very explicitly break 32-bit application execution!\n "
296- " Use at your own risk!" )
295+ if (BUILD_TESTING)
296+ include (Catch)
297297endif ()
298298
299299if (USE_PDB_DEBUGINFO)
@@ -307,71 +307,18 @@ set (CMAKE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_LINKER_FLAGS_RELWITHDEBINFO} -fn
307307set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer" )
308308set (CMAKE_LINKER_FLAGS_RELEASE "${CMAKE_LINKER_FLAGS_RELEASE} -fomit-frame-pointer" )
309309
310- include_directories (External/robin-map/include /)
311-
312- include (CTest)
313- if (BUILD_TESTING OR ENABLE_VIXL_DISASSEMBLER OR ENABLE_VIXL_SIMULATOR)
314- add_subdirectory (External/vixl/)
315- include_directories (SYSTEM External/vixl/src/)
316- endif ()
317-
318- if (ENABLE_FEXCORE_PROFILER AND FEXCORE_PROFILER_BACKEND STREQUAL "TRACY" )
319- add_subdirectory (External/tracy)
320- endif ()
321-
322310if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
323311 # This means we were attempted to get compiled with GCC
324312 message (FATAL_ERROR "FEX doesn't support getting compiled with GCC!" )
325313endif ()
326314
327- find_package (PkgConfig REQUIRED)
328315find_package (Python 3.9 REQUIRED COMPONENTS Interpreter)
329316
330- set (BUILD_SHARED_LIBS OFF )
331-
332- pkg_search_module(xxhash IMPORTED_TARGET xxhash libxxhash)
333- if (TARGET PkgConfig::xxhash AND NOT CMAKE_CROSSCOMPILING )
334- add_library (xxHash::xxhash ALIAS PkgConfig::xxhash)
335- else ()
336- set (XXHASH_BUNDLED_MODE TRUE )
337- set (XXHASH_BUILD_XXHSUM FALSE )
338- add_subdirectory (External/xxhash/cmake_unofficial/)
339- endif ()
317+ include (CTest)
340318
341319add_definitions (-Wno-trigraphs)
342320add_definitions (-DGLOBAL_DATA_DIRECTORY="${DATA_DIRECTORY} /" )
343321
344- if (BUILD_TESTING)
345- find_package (Catch2 3 QUIET )
346- if (NOT Catch2_FOUND)
347- add_subdirectory (External/Catch2/)
348-
349- # Pull in catch_discover_tests definition
350- list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /External/Catch2/contrib/" )
351- endif ()
352-
353- include (Catch)
354- else ()
355- # Override any previously generated test list to avoid running stale test binaries
356- file (GENERATE OUTPUT CTestTestfile.cmake CONTENT "# No tests since BUILD_TESTING is disabled" )
357- endif ()
358-
359- find_package (fmt QUIET )
360- if (NOT fmt_FOUND)
361- # Disable fmt install
362- set (FMT_INSTALL OFF )
363- add_subdirectory (External/fmt/)
364- endif ()
365-
366- find_package (range-v3 QUIET )
367- if (NOT range-v3_FOUND)
368- add_subdirectory (External/range-v3/)
369- target_compile_definitions (range-v3 INTERFACE RANGES_DISABLE_DEPRECATED_WARNINGS)
370- endif ()
371-
372- add_subdirectory (External/tiny-json/)
373- include_directories (External/tiny-json/)
374-
375322include_directories (Source /)
376323include_directories ("${CMAKE_BINARY_DIR} /Source/" )
377324
@@ -512,8 +459,6 @@ if (BUILD_TESTING)
512459 set (TEST_JOB_FLAG "-j${TEST_JOB_COUNT} " )
513460endif ()
514461
515- add_subdirectory (External/SoftFloat-3e/)
516- add_subdirectory (External/cephes/)
517462add_subdirectory (FEXHeaderUtils/)
518463add_subdirectory (CodeEmitter/)
519464add_subdirectory (FEXCore/)
@@ -544,6 +489,10 @@ if (BUILD_TESTING)
544489endif ()
545490
546491if (BUILD_THUNKS)
492+ if (TARGET Vulkan::Headers)
493+ message (STATUS "Vulkan exists" )
494+ endif ()
495+
547496 set (FEX_PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR} )
548497 add_subdirectory (ThunkLibs/Generator)
549498
@@ -553,6 +502,7 @@ if (BUILD_THUNKS)
553502 # Thunk targets for IDE integration of guest code, only
554503 add_subdirectory (ThunkLibs/GuestLibs)
555504
505+ # TODO(crueter): Move to CPM
556506 # Thunk targets for guest libraries
557507 include (ExternalProject)
558508 ExternalProject_Add(guest-libs
0 commit comments