diff --git a/CMakeLists.txt b/CMakeLists.txt index 23c36741..ee3e837a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,11 @@ project(drjit-core # Optional features available to users # ---------------------------------------------------------- +option(DRJIT_USE_SYSTEM_NANOTHREAD "Use the system nanothread library?" OFF) +option(DRJIT_USE_SYSTEM_LZ4 "Use the system lz4 library?" OFF) +option(DRJIT_USE_SYSTEM_XXHASH "Use the system xxHash library?" OFF) +option(DRJIT_USE_SYSTEM_TSL_ROBIN_MAP "Use the system tsl-robin-map library?" OFF) + option(DRJIT_DYNAMIC_LLVM "Resolve LLVM dynamically at run time?" ON) option(DRJIT_ENABLE_TESTS "Build Dr.Jit-Core test suite?" OFF) @@ -43,6 +48,11 @@ include(ext/nanothread/ext/cmake-defaults/CMakeLists.txt) # Print a few messages explaining what will be compiled # ---------------------------------------------------------- +message(STATUS "Dr.Jit-Core: using system nanothread: ${DRJIT_USE_SYSTEM_NANOTHREAD}") +message(STATUS "Dr.Jit-Core: using system lz4: ${DRJIT_USE_SYSTEM_LZ4}") +message(STATUS "Dr.Jit-Core: using system xxHash: ${DRJIT_USE_SYSTEM_XXHASH}") +message(STATUS "Dr.Jit-Core: using system tsl-robin-map: ${DRJIT_USE_SYSTEM_TSL_ROBIN_MAP}") + if (DRJIT_DYNAMIC_LLVM) message(STATUS "Dr.Jit-Core: LLVM will be loaded dynamically at runtime.") else() @@ -73,32 +83,33 @@ endif() # Find or build the dependencies # ---------------------------------------------------------- -find_package(nanothread) -if (NOT nanothread_FOUND) +if (DRJIT_USE_SYSTEM_NANOTHREAD) + find_package(nanothread REQUIRED) +else() add_subdirectory(ext/nanothread) mark_as_advanced(NANOTHREAD_ENABLE_TESTS) endif() -find_package(PkgConfig) -if (PkgConfig_FOUND) +if (DRJIT_USE_SYSTEM_LZ4) + find_package(PkgConfig REQUIRED) pkg_check_modules(lz4 liblz4 IMPORTED_TARGET) add_library(lz4 ALIAS PkgConfig::lz4) -endif() -if(NOT lz4_FOUND) +else() add_library(lz4 ext/lz4/lz4.c) target_include_directories(lz4 PUBLIC ext/lz4) endif() -find_package(xxHash) -if (NOT xxHash_FOUND) +if (DRJIT_USE_SYSTEM_XXHASH) + find_package(xxHash REQUIRED) +else() add_library(xxhash ext/lz4/xxhash.c) target_include_directories(xxhash PUBLIC ext/lz4) - add_library(xxHash::xxhash ALIAS xxhash) endif() -find_package(tsl-robin-map) -if (NOT tsl-robin-map_FOUND) +if (DRJIT_USE_SYSTEM_TSL_ROBIN_MAP) + find_package(tsl-robin-map REQUIRED) +else() add_subdirectory(ext/robin_map) endif()