Skip to content

Commit 9a07fdb

Browse files
authored
Merge pull request #3345 from eseiler/fix/find_package
[FIX] Do not find_package yourself
2 parents d48a8c3 + 26c5cbe commit 9a07fdb

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ project (seqan3
1919
DESCRIPTION "SeqAn3 -- the modern C++ library for sequence analysis"
2020
HOMEPAGE_URL "https://github.com/seqan/seqan3")
2121

22-
find_package (SeqAn3 3.0 REQUIRED HINTS ${SEQAN3_MODULE_PATH})
22+
include (seqan3-config)
2323

2424
option (INSTALL_SEQAN3 "Enable installation of seqan3. (Projects embedding seqan3 may want to turn this OFF.)" ON)
2525

cmake/seqan3-config.cmake

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -281,24 +281,28 @@ endif ()
281281
# Finish find_package call
282282
# ----------------------------------------------------------------------------
283283

284-
find_package_handle_standard_args (${CMAKE_FIND_PACKAGE_NAME} REQUIRED_VARS SEQAN3_INCLUDE_DIR)
285-
286-
# Set SEQAN3_* variables with the content of ${CMAKE_FIND_PACKAGE_NAME}_(FOUND|...|VERSION)
287-
# This needs to be done, because `find_package(SeqAn3)` might be called in any case-sensitive way and we want to
288-
# guarantee that SEQAN3_* are always set.
289-
foreach (package_var
290-
FOUND
291-
DIR
292-
ROOT
293-
CONFIG
294-
VERSION
295-
VERSION_MAJOR
296-
VERSION_MINOR
297-
VERSION_PATCH
298-
VERSION_TWEAK
299-
VERSION_COUNT)
300-
set (SEQAN3_${package_var} "${${CMAKE_FIND_PACKAGE_NAME}_${package_var}}")
301-
endforeach ()
284+
if (CMAKE_FIND_PACKAGE_NAME)
285+
find_package_handle_standard_args (${CMAKE_FIND_PACKAGE_NAME} REQUIRED_VARS SEQAN3_INCLUDE_DIR)
286+
287+
# Set SEQAN3_* variables with the content of ${CMAKE_FIND_PACKAGE_NAME}_(FOUND|...|VERSION)
288+
# This needs to be done, because `find_package(SeqAn3)` might be called in any case-sensitive way and we want to
289+
# guarantee that SEQAN3_* are always set.
290+
foreach (package_var
291+
FOUND
292+
DIR
293+
ROOT
294+
CONFIG
295+
VERSION
296+
VERSION_MAJOR
297+
VERSION_MINOR
298+
VERSION_PATCH
299+
VERSION_TWEAK
300+
VERSION_COUNT)
301+
set (SEQAN3_${package_var} "${${CMAKE_FIND_PACKAGE_NAME}_${package_var}}")
302+
endforeach ()
303+
else ()
304+
set (SEQAN3_VERSION "${PACKAGE_VERSION}")
305+
endif ()
302306

303307
# propagate SEQAN3_INCLUDE_DIR into SEQAN3_INCLUDE_DIRS
304308
set (SEQAN3_INCLUDE_DIRS ${SEQAN3_INCLUDE_DIR})
@@ -307,7 +311,7 @@ set (SEQAN3_INCLUDE_DIRS ${SEQAN3_INCLUDE_DIR})
307311
# Export targets
308312
# ----------------------------------------------------------------------------
309313

310-
if (SEQAN3_FOUND AND NOT TARGET seqan3::seqan3)
314+
if (NOT TARGET seqan3::seqan3)
311315
add_library (seqan3_seqan3 INTERFACE)
312316
target_compile_definitions (seqan3_seqan3 INTERFACE ${SEQAN3_DEFINITIONS})
313317
target_compile_features (seqan3_seqan3 INTERFACE cxx_std_23)

0 commit comments

Comments
 (0)