-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake Superbuild: Repo & Local Source
Support controlling remote repo links, branches/tags or local source directories for superbuilds.
- Loading branch information
Showing
6 changed files
with
274 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
function(find_catch2) | ||
if(TARGET Catch2::Catch2) | ||
message(STATUS "Catch2::Catch2 target already imported") | ||
elseif(openPMD_catch_src) | ||
message(STATUS "Compiling local Catch2 ...") | ||
message(STATUS "Catch2 source path: ${openPMD_catch_src}") | ||
if(NOT IS_DIRECTORY ${openPMD_catch_src}) | ||
message(FATAL_ERROR "Specified directory openPMD_catch_src='${openPMD_catch_src}' does not exist!") | ||
endif() | ||
elseif(openPMD_USE_INTERNAL_CATCH) | ||
message(STATUS "Downloading Catch2 ...") | ||
message(STATUS "Catch2 repository: ${openPMD_catch_repo} (${openPMD_catch_branch})") | ||
include(FetchContent) | ||
endif() | ||
if(TARGET Catch2::Catch2) | ||
# nothing to do, target already exists in the superbuild | ||
elseif(openPMD_USE_INTERNAL_CATCH OR openPMD_catch_src) | ||
if(openPMD_catch_src) | ||
add_subdirectory(${openPMD_catch_src} _deps/localCatch2-build/) | ||
else() | ||
FetchContent_Declare(fetchedCatch2 | ||
GIT_REPOSITORY ${openPMD_catch_repo} | ||
GIT_TAG ${openPMD_catch_branch} | ||
BUILD_IN_SOURCE 0 | ||
) | ||
FetchContent_MakeAvailable(fetchedCatch2) | ||
|
||
# advanced fetch options | ||
mark_as_advanced(FETCHCONTENT_BASE_DIR) | ||
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) | ||
mark_as_advanced(FETCHCONTENT_QUIET) | ||
#mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FETCHEDCatch2) | ||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) | ||
#mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDCatch2) | ||
endif() | ||
elseif(NOT openPMD_USE_INTERNAL_CATCH) | ||
find_package(Catch2 2.13.10 CONFIG REQUIRED) | ||
message(STATUS "Catch2: Found version '${Catch2_VERSION}'") | ||
endif() | ||
endfunction() | ||
|
||
# local source-tree | ||
set(openPMD_catch_src "" | ||
CACHE PATH | ||
"Local path to Catch2 source directory (preferred if set)") | ||
|
||
# Git fetcher | ||
set(openPMD_catch_repo "https://github.com/catchorg/Catch2.git" | ||
CACHE STRING | ||
"Repository URI to pull and build Catch2 from if(openPMD_USE_INTERNAL_CATCH)") | ||
set(openPMD_catch_branch "v2.13.10" | ||
CACHE STRING | ||
"Repository branch for openPMD_catch_repo if(openPMD_USE_INTERNAL_CATCH)") | ||
|
||
find_catch2() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
function(find_json) | ||
if(TARGET nlohmann_json::nlohmann_json) | ||
message(STATUS "nlohmann_json::nlohmann_json target already imported") | ||
elseif(openPMD_json_src) | ||
message(STATUS "Compiling local nlohmann_json ...") | ||
message(STATUS "nlohmann_json source path: ${openPMD_json_src}") | ||
if(NOT IS_DIRECTORY ${openPMD_json_src}) | ||
message(FATAL_ERROR "Specified directory openPMD_json_src='${openPMD_json_src}' does not exist!") | ||
endif() | ||
elseif(openPMD_USE_INTERNAL_JSON) | ||
message(STATUS "Downloading nlohmann_json ...") | ||
message(STATUS "nlohmann_json repository: ${openPMD_json_repo} (${openPMD_json_branch})") | ||
include(FetchContent) | ||
endif() | ||
if(TARGET nlohmann_json::nlohmann_json) | ||
# nothing to do, target already exists in the superbuild | ||
elseif(openPMD_USE_INTERNAL_JSON OR openPMD_json_src) | ||
if(openPMD_json_src) | ||
add_subdirectory(${openPMD_json_src} _deps/localnlohmann_json-build/) | ||
else() | ||
FetchContent_Declare(fetchednlohmann_json | ||
GIT_REPOSITORY ${openPMD_json_repo} | ||
GIT_TAG ${openPMD_json_branch} | ||
BUILD_IN_SOURCE 0 | ||
) | ||
FetchContent_MakeAvailable(fetchednlohmann_json) | ||
|
||
# advanced fetch options | ||
mark_as_advanced(FETCHCONTENT_BASE_DIR) | ||
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) | ||
mark_as_advanced(FETCHCONTENT_QUIET) | ||
#mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FETCHEDnlohmann_json) | ||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) | ||
#mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDnlohmann_json) | ||
endif() | ||
elseif(NOT openPMD_USE_INTERNAL_JSON) | ||
find_package(nlohmann_json 3.9.1 CONFIG REQUIRED) | ||
message(STATUS "nlohmann_json: Found version '${nlohmann_json_VERSION}'") | ||
endif() | ||
endfunction() | ||
|
||
# local source-tree | ||
set(openPMD_json_src "" | ||
CACHE PATH | ||
"Local path to nlohmann_json source directory (preferred if set)") | ||
|
||
# Git fetcher | ||
set(openPMD_json_repo "https://github.com/nlohmann/json.git" | ||
CACHE STRING | ||
"Repository URI to pull and build nlohmann_json from if(openPMD_USE_INTERNAL_JSON)") | ||
set(openPMD_json_branch "v3.11.3" | ||
CACHE STRING | ||
"Repository branch for openPMD_json_repo if(openPMD_USE_INTERNAL_JSON)") | ||
|
||
find_json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
function(find_pybind11) | ||
if(TARGET pybind11::module) | ||
message(STATUS "pybind11::module target already imported") | ||
elseif(openPMD_pybind11_src) | ||
message(STATUS "Compiling local pybind11 ...") | ||
message(STATUS "pybind11 source path: ${openPMD_pybind11_src}") | ||
if(NOT IS_DIRECTORY ${openPMD_pybind11_src}) | ||
message(FATAL_ERROR "Specified directory openPMD_pybind11_src='${openPMD_pybind11_src}' does not exist!") | ||
endif() | ||
elseif(openPMD_USE_INTERNAL_PYBIND11) | ||
message(STATUS "Downloading pybind11 ...") | ||
message(STATUS "pybind11 repository: ${openPMD_pybind11_repo} (${openPMD_pybind11_branch})") | ||
include(FetchContent) | ||
endif() | ||
if(TARGET pybind11::module) | ||
# nothing to do, target already exists in the superbuild | ||
elseif(openPMD_USE_INTERNAL_PYBIND11 OR openPMD_pybind11_src) | ||
if(openPMD_pybind11_src) | ||
add_subdirectory(${openPMD_pybind11_src} _deps/localpybind11-build/) | ||
else() | ||
FetchContent_Declare(fetchedpybind11 | ||
GIT_REPOSITORY ${openPMD_pybind11_repo} | ||
GIT_TAG ${openPMD_pybind11_branch} | ||
BUILD_IN_SOURCE 0 | ||
) | ||
FetchContent_MakeAvailable(fetchedpybind11) | ||
|
||
# advanced fetch options | ||
mark_as_advanced(FETCHCONTENT_BASE_DIR) | ||
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) | ||
mark_as_advanced(FETCHCONTENT_QUIET) | ||
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FETCHEDpybind11) | ||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) | ||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDpybind11) | ||
endif() | ||
elseif(NOT openPMD_USE_INTERNAL_PYBIND11) | ||
if(openPMD_USE_PYTHON STREQUAL AUTO) | ||
find_package(pybind11 2.12.0 CONFIG) | ||
elseif(openPMD_USE_PYTHON) | ||
find_package(pybind11 2.12.0 CONFIG REQUIRED) | ||
endif() | ||
if(TARGET pybind11::module) | ||
message(STATUS "pybind11: Found version '${pybind11_VERSION}'") | ||
endif() | ||
endif() | ||
endfunction() | ||
|
||
# local source-tree | ||
set(openPMD_pybind11_src "" | ||
CACHE PATH | ||
"Local path to pybind11 source directory (preferred if set)") | ||
|
||
# Git fetcher | ||
set(openPMD_pybind11_repo "https://github.com/pybind/pybind11.git" | ||
CACHE STRING | ||
"Repository URI to pull and build pybind11 from if(openPMD_USE_INTERNAL_PYBIND11)") | ||
set(openPMD_pybind11_branch "v2.12.0" | ||
CACHE STRING | ||
"Repository branch for openPMD_pybind11_repo if(openPMD_USE_INTERNAL_PYBIND11)") | ||
|
||
if(openPMD_USE_PYTHON STREQUAL AUTO) | ||
find_package(Python 3.7.0 COMPONENTS Interpreter Development.Module) | ||
elseif(openPMD_USE_PYTHON) | ||
find_package(Python 3.7.0 COMPONENTS Interpreter Development.Module REQUIRED) | ||
else() | ||
set(openPMD_HAVE_PYTHON FALSE) | ||
endif() | ||
|
||
if(Python_FOUND) | ||
find_pybind11() | ||
endif() | ||
|
||
if(TARGET pybind11::module) | ||
set(openPMD_HAVE_PYTHON TRUE) | ||
else() | ||
set(openPMD_HAVE_PYTHON FALSE) | ||
endif() |
Oops, something went wrong.