Skip to content

Commit

Permalink
cmake: add flags to use system-provided libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorBaker authored and Connor Baker committed Jan 31, 2024
1 parent 12a5301 commit b843b9c
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit b843b9c

Please sign in to comment.