Skip to content

Commit 00aeb70

Browse files
committed
WIP: [cmake] allow fetching deps with CPM instead of submodules
Extremely WIP, thunks and tests are untested since I don't have an aarch64 development environment on me at the time. Will document this later. Signed-off-by: crueter <[email protected]>
1 parent 499970d commit 00aeb70

File tree

16 files changed

+1649
-91
lines changed

16 files changed

+1649
-91
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ out/
1111
.vs/
1212
*.pyc
1313
.cache
14+
.qtcreator

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
[submodule "External/robin-map"]
3636
shallow = true
3737
path = External/robin-map
38-
url = https://github.com/FEX-Emu/robin-map.git
38+
url = https://github.com/crueter/robin-map.git
3939
[submodule "External/Vulkan-Headers"]
4040
shallow = true
4141
path = External/Vulkan-Headers

CMakeLists.txt

Lines changed: 27 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ set (FEXCORE_PROFILER_BACKEND "gpuvis" CACHE STRING "Set which backend to use fo
3434
option(ENABLE_GLIBC_ALLOCATOR_HOOK_FAULT "Enables glibc memory allocation hooking with fault for CI testing")
3535
option(USE_PDB_DEBUGINFO "Builds debug info in PDB format" FALSE)
3636
option(BUILD_STEAM_SUPPORT "Builds FEX for integration into Steam" FALSE)
37+
option(USE_CPM "Fetch externals with CPM instead of submodules" FALSE)
3738

3839
set (X86_32_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Data/CMake/toolchain_x86_32.cmake" CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting i686")
3940
set (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)
7071
endif()
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+
7282
if (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)
137147
endif()
138148

139-
140149
set(CMAKE_CXX_STANDARD 20)
141150
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
142151
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Bin)
@@ -272,28 +281,19 @@ if (ENABLE_COVERAGE)
272281
link_libraries(-fprofile-instr-generate -fcoverage-mapping)
273282
endif()
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()
286293
endif()
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)
297297
endif()
298298

299299
if (USE_PDB_DEBUGINFO)
@@ -307,71 +307,18 @@ set (CMAKE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_LINKER_FLAGS_RELWITHDEBINFO} -fn
307307
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
308308
set (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-
322310
if (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!")
325313
endif()
326314

327-
find_package(PkgConfig REQUIRED)
328315
find_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

341319
add_definitions(-Wno-trigraphs)
342320
add_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-
375322
include_directories(Source/)
376323
include_directories("${CMAKE_BINARY_DIR}/Source/")
377324

@@ -512,8 +459,6 @@ if (BUILD_TESTING)
512459
set(TEST_JOB_FLAG "-j${TEST_JOB_COUNT}")
513460
endif()
514461

515-
add_subdirectory(External/SoftFloat-3e/)
516-
add_subdirectory(External/cephes/)
517462
add_subdirectory(FEXHeaderUtils/)
518463
add_subdirectory(CodeEmitter/)
519464
add_subdirectory(FEXCore/)
@@ -544,6 +489,10 @@ if (BUILD_TESTING)
544489
endif()
545490

546491
if (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

Comments
 (0)