Skip to content

Commit dbc6006

Browse files
committed
Only include externals when actually needed
This adds an option to use the system library for HIDAPI if enabled, and gates the misc and regex external libraries to only the platforms where they're actually needed.
1 parent 5736b0f commit dbc6006

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Diff for: CMakeLists.txt

+15-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ option(FORCE_SSE "Compile with SSE instruction only" ON)
1414
option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF)
1515
option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF)
1616
option(OPTIONAL_TEST "Compile optional test (might be broken)" OFF)
17+
option(USE_SYSTEM_HIDAPI "Use the system library for hidapi" OFF)
1718
# UNITTEST option must be after CMAKE_BUILT_TYPE
1819

1920
# where cmake find custom modules
@@ -72,7 +73,11 @@ set(CUSTOM_SRC_DIR "${CMAKE_SOURCE_DIR}/src")
7273
set(CUSTOM_EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external")
7374
set(CUSTOM_MISC_DIR "${CUSTOM_EXTERNAL_DIR}/misc")
7475
set(CUSTOM_REGEX_DIR "${CUSTOM_EXTERNAL_DIR}/regex")
75-
set(CUSTOM_HIDAPI_DIR "${CUSTOM_EXTERNAL_DIR}/hidapi")
76+
if(USE_SYSTEM_HIDAPI)
77+
find_package(hidapi REQUIRED)
78+
else()
79+
set(CUSTOM_HIDAPI_DIR "${CUSTOM_EXTERNAL_DIR}/hidapi")
80+
endif()
7681
set(CUSTOM_GEOTRANZ_DIR "${CUSTOM_EXTERNAL_DIR}/geotranz")
7782
set(CUSTOM_DATA_DIR "${CMAKE_SOURCE_DIR}/data")
7883
set(CUSTOM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/scripts")
@@ -374,9 +379,15 @@ add_subdirectory(data)
374379

375380
# external libraries
376381
add_subdirectory(${CUSTOM_GEOTRANZ_DIR})
377-
add_subdirectory(${CUSTOM_REGEX_DIR})
378-
add_subdirectory(${CUSTOM_HIDAPI_DIR})
379-
add_subdirectory(${CUSTOM_MISC_DIR})
382+
if(WIN32)
383+
add_subdirectory(${CUSTOM_REGEX_DIR})
384+
endif()
385+
if(NOT USE_SYSTEM_HIDAPI)
386+
add_subdirectory(${CUSTOM_HIDAPI_DIR})
387+
endif()
388+
if(NOT LINUX)
389+
add_subdirectory(${CUSTOM_MISC_DIR})
390+
endif()
380391

381392
# direwolf source code and utilities
382393
add_subdirectory(src)

0 commit comments

Comments
 (0)