Skip to content

Commit b843b9c

Browse files
ConnorBakerConnor Baker
authored and
Connor Baker
committed
cmake: add flags to use system-provided libraries
1 parent 12a5301 commit b843b9c

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

CMakeLists.txt

+22-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ project(drjit-core
1414
# Optional features available to users
1515
# ----------------------------------------------------------
1616

17+
option(DRJIT_USE_SYSTEM_NANOTHREAD "Use the system nanothread library?" OFF)
18+
option(DRJIT_USE_SYSTEM_LZ4 "Use the system lz4 library?" OFF)
19+
option(DRJIT_USE_SYSTEM_XXHASH "Use the system xxHash library?" OFF)
20+
option(DRJIT_USE_SYSTEM_TSL_ROBIN_MAP "Use the system tsl-robin-map library?" OFF)
21+
1722
option(DRJIT_DYNAMIC_LLVM "Resolve LLVM dynamically at run time?" ON)
1823
option(DRJIT_ENABLE_TESTS "Build Dr.Jit-Core test suite?" OFF)
1924

@@ -43,6 +48,11 @@ include(ext/nanothread/ext/cmake-defaults/CMakeLists.txt)
4348
# Print a few messages explaining what will be compiled
4449
# ----------------------------------------------------------
4550

51+
message(STATUS "Dr.Jit-Core: using system nanothread: ${DRJIT_USE_SYSTEM_NANOTHREAD}")
52+
message(STATUS "Dr.Jit-Core: using system lz4: ${DRJIT_USE_SYSTEM_LZ4}")
53+
message(STATUS "Dr.Jit-Core: using system xxHash: ${DRJIT_USE_SYSTEM_XXHASH}")
54+
message(STATUS "Dr.Jit-Core: using system tsl-robin-map: ${DRJIT_USE_SYSTEM_TSL_ROBIN_MAP}")
55+
4656
if (DRJIT_DYNAMIC_LLVM)
4757
message(STATUS "Dr.Jit-Core: LLVM will be loaded dynamically at runtime.")
4858
else()
@@ -73,32 +83,33 @@ endif()
7383
# Find or build the dependencies
7484
# ----------------------------------------------------------
7585

76-
find_package(nanothread)
77-
if (NOT nanothread_FOUND)
86+
if (DRJIT_USE_SYSTEM_NANOTHREAD)
87+
find_package(nanothread REQUIRED)
88+
else()
7889
add_subdirectory(ext/nanothread)
7990
mark_as_advanced(NANOTHREAD_ENABLE_TESTS)
8091
endif()
8192

82-
find_package(PkgConfig)
83-
if (PkgConfig_FOUND)
93+
if (DRJIT_USE_SYSTEM_LZ4)
94+
find_package(PkgConfig REQUIRED)
8495
pkg_check_modules(lz4 liblz4 IMPORTED_TARGET)
8596
add_library(lz4 ALIAS PkgConfig::lz4)
86-
endif()
87-
if(NOT lz4_FOUND)
97+
else()
8898
add_library(lz4 ext/lz4/lz4.c)
8999
target_include_directories(lz4 PUBLIC ext/lz4)
90100
endif()
91101

92-
find_package(xxHash)
93-
if (NOT xxHash_FOUND)
102+
if (DRJIT_USE_SYSTEM_XXHASH)
103+
find_package(xxHash REQUIRED)
104+
else()
94105
add_library(xxhash ext/lz4/xxhash.c)
95106
target_include_directories(xxhash PUBLIC ext/lz4)
96-
97107
add_library(xxHash::xxhash ALIAS xxhash)
98108
endif()
99109

100-
find_package(tsl-robin-map)
101-
if (NOT tsl-robin-map_FOUND)
110+
if (DRJIT_USE_SYSTEM_TSL_ROBIN_MAP)
111+
find_package(tsl-robin-map REQUIRED)
112+
else()
102113
add_subdirectory(ext/robin_map)
103114
endif()
104115

0 commit comments

Comments
 (0)