Skip to content

Commit

Permalink
Merge pull request #389 from ax3l/topic-jsonSystemIncl
Browse files Browse the repository at this point in the history
ThirdParty Libs: IMPORTED
  • Loading branch information
ax3l authored Dec 1, 2018
2 parents ed4069d + 0c85a24 commit d5f5175
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 41 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cache:
apt: true
directories:
- $HOME/.cache/spack
- $HOME/.cache/cmake-3.10.0
- $HOME/.cache/cmake-3.11.0
- $HOME/.cache/kcov-35
- $HOME/Library/Caches/Homebrew
pip: true
Expand Down Expand Up @@ -494,26 +494,26 @@ install:
export MODULEPATH=$SPACK_ROOT/share/spack/modules/$(spack arch):$MODULEPATH;
fi
- SPACK_VAR_MPI="~mpi";
# required dependencies - CMake 3.10.0
# required dependencies - CMake 3.11.0
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
if [ ! -f $HOME/.cache/cmake-3.10.0/bin/cmake ]; then
wget -O cmake.sh https://cmake.org/files/v3.10/cmake-3.10.0-Linux-x86_64.sh &&
sh cmake.sh --skip-license --exclude-subdir --prefix=$HOME/.cache/cmake-3.10.0 &&
if [ ! -f $HOME/.cache/cmake-3.11.0/bin/cmake ]; then
wget -O cmake.sh https://cmake.org/files/v3.11/cmake-3.11.0-Linux-x86_64.sh &&
sh cmake.sh --skip-license --exclude-subdir --prefix=$HOME/.cache/cmake-3.11.0 &&
rm cmake.sh;
fi;
else
if [ ! -d /Applications/CMake.app/Contents/ ]; then
curl -L -s -o cmake.dmg https://cmake.org/files/v3.10/cmake-3.10.0-Darwin-x86_64.dmg &&
curl -L -s -o cmake.dmg https://cmake.org/files/v3.11/cmake-3.11.0-Darwin-x86_64.dmg &&
yes | hdiutil mount cmake.dmg &&
sudo cp -R "/Volumes/cmake-3.10.0-Darwin-x86_64/CMake.app" /Applications &&
sudo cp -R "/Volumes/cmake-3.11.0-Darwin-x86_64/CMake.app" /Applications &&
hdiutil detach /dev/disk1s1 &&
rm cmake.dmg;
fi;
fi
- spack install
cmake@3.10.0
cmake@3.11.0
$CXXSPEC
- spack load cmake@3.10.0 $CXXSPEC
- spack load cmake@3.11.0 $CXXSPEC
# diagnostics: modules created and visible?
- module av
- module li
Expand Down
16 changes: 8 additions & 8 deletions .travis/spack/packages.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
packages:
cmake:
version: [3.10.0]
version: [3.11.0]
paths:
cmake@3.10.0%gcc@4.8.5 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.10.0
cmake@3.10.0%gcc@4.9.4 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.10.0
cmake@3.10.0%gcc@6.4.0 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.10.0
cmake@3.10.0%gcc@7.3.0 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.10.0
cmake@3.10.0%gcc@8.1.0 arch=linux-ubuntu16-x86_64: /home/travis/.cache/cmake-3.10.0
cmake@3.10.0%clang@5.0.0 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.10.0
cmake@3.10.0%clang@9.1.0 arch=darwin-highsierra-x86_64: /Applications/CMake.app/Contents/
cmake@3.11.0%gcc@4.8.5 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.11.0
cmake@3.11.0%gcc@4.9.4 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.11.0
cmake@3.11.0%gcc@6.4.0 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.11.0
cmake@3.11.0%gcc@7.3.0 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.11.0
cmake@3.11.0%gcc@8.1.0 arch=linux-ubuntu16-x86_64: /home/travis/.cache/cmake-3.11.0
cmake@3.11.0%clang@5.0.0 arch=linux-ubuntu14-x86_64: /home/travis/.cache/cmake-3.11.0
cmake@3.11.0%clang@9.1.0 arch=darwin-highsierra-x86_64: /Applications/CMake.app/Contents/
buildable: False
openmpi:
version: [1.6.5]
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Other

- Docs: upgrade guide added #385
- CI: GCC 8.1.0 & Python 3.7.0 #376
- CMake: treat third party libraries properly as ``IMPORTED`` #389


0.6.2-alpha
Expand Down
40 changes: 23 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Preamble ####################################################################
#
cmake_minimum_required(VERSION 3.10.0)
cmake_minimum_required(VERSION 3.11.0)

project(openPMD VERSION 0.6.2) # LANGUAGES CXX

Expand Down Expand Up @@ -125,6 +125,11 @@ elseif(openPMD_USE_JSON)
else()
set(openPMD_HAVE_JSON FALSE)
endif()
if(openPMD_HAVE_JSON)
add_library(openPMD::thirdparty::nlohmann_json INTERFACE IMPORTED)
target_link_libraries(openPMD::thirdparty::nlohmann_json
INTERFACE nlohmann_json::nlohmann_json)
endif()

# external library: HDF5 (optional)
if(openPMD_USE_HDF5 STREQUAL AUTO)
Expand Down Expand Up @@ -265,6 +270,11 @@ elseif(openPMD_USE_PYTHON)
else()
set(openPMD_HAVE_PYTHON FALSE)
endif()
if(openPMD_HAVE_PYTHON)
add_library(openPMD::thirdparty::pybind11 INTERFACE IMPORTED)
target_link_libraries(openPMD::thirdparty::pybind11
INTERFACE pybind11::pybind11)
endif()


# Targets #####################################################################
Expand Down Expand Up @@ -331,26 +341,31 @@ target_include_directories(openPMD PUBLIC
)

# C++11 std::variant (C++17 stdlib preview)
add_library(openPMD::thirdparty::mpark_variant INTERFACE IMPORTED)
if(openPMD_USE_INTERNAL_VARIANT)
target_include_directories(openPMD SYSTEM PUBLIC
target_include_directories(openPMD::thirdparty::mpark_variant SYSTEM INTERFACE
$<BUILD_INTERFACE:${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/variant/include>
)
message(STATUS "MPark.Variant: Using INTERNAL version 1.3.0")
else()
find_package(mpark_variant 1.3.0 REQUIRED)
target_link_libraries(openPMD PUBLIC mpark_variant)
target_link_libraries(openPMD::thirdparty::mpark_variant
INTERFACE mpark_variant)
message(STATUS "MPark.Variant: Found version ${mpark_variant_VERSION}")
endif()

# Catch2 for unit tests
if(BUILD_TESTING)
add_library(openPMD::thirdparty::Catch2 INTERFACE IMPORTED)
if(openPMD_USE_INTERNAL_CATCH)
target_include_directories(openPMD SYSTEM PUBLIC
target_include_directories(openPMD::thirdparty::Catch2 SYSTEM INTERFACE
$<BUILD_INTERFACE:${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/catch2/include>
)
message(STATUS "Catch2: Using INTERNAL version 2.3.0")
else()
find_package(Catch2 2.3.0 CONFIG REQUIRED)
target_link_libraries(openPMD::thirdparty::Catch2
INTERFACE Catch2::Catch2)
message(STATUS "Catch2: Found version ${Catch2_VERSION}")
endif()
endif()
Expand All @@ -367,7 +382,7 @@ endif()

# JSON Backend
if(openPMD_HAVE_JSON)
target_link_libraries(openPMD PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(openPMD PRIVATE openPMD::thirdparty::nlohmann_json)
target_compile_definitions(openPMD PUBLIC "-DopenPMD_HAVE_JSON=1")
else()
target_compile_definitions(openPMD PUBLIC "-DopenPMD_HAVE_JSON=0")
Expand Down Expand Up @@ -396,15 +411,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(openPMD.ADIOS1.Serial PUBLIC "/bigobj")
target_compile_options(openPMD.ADIOS1.Parallel PUBLIC "/bigobj")
endif()
if(openPMD_USE_INTERNAL_VARIANT)
target_include_directories(openPMD.ADIOS1.Serial SYSTEM PUBLIC
$<BUILD_INTERFACE:${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/variant/include>)
target_include_directories(openPMD.ADIOS1.Parallel SYSTEM PUBLIC
$<BUILD_INTERFACE:${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/variant/include>)
else()
target_link_libraries(openPMD.ADIOS1.Serial PUBLIC mpark_variant)
target_link_libraries(openPMD.ADIOS1.Parallel PUBLIC mpark_variant)
endif()
target_link_libraries(openPMD.ADIOS1.Serial PUBLIC openPMD::thirdparty::mpark_variant)
target_link_libraries(openPMD.ADIOS1.Parallel PUBLIC openPMD::thirdparty::mpark_variant)

target_include_directories(openPMD.ADIOS1.Serial SYSTEM PRIVATE
${openPMD_SOURCE_DIR}/include)
Expand Down Expand Up @@ -615,9 +623,7 @@ if(BUILD_TESTING)
target_compile_definitions(${testname}Tests PUBLIC "-DopenPMD_HAVE_ADIOS2=1")
endif()
target_link_libraries(${testname}Tests PRIVATE openPMD)
if(TARGET Catch2::Catch2)
target_link_libraries(${testname}Tests PRIVATE Catch2::Catch2)
endif()
target_link_libraries(${testname}Tests PRIVATE openPMD::thirdparty::Catch2)
endforeach()
endif()

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN if [ ! -d $HOME/src/openPMD-api/samples/git-sample/ ]; then \

ARG CMAKE_VERSION
ARG CMAKE_PATCH
# install CMake (can be deprecated when CMake >=3.10 is default in 16.04)
# install CMake (can be deprecated when CMake >=3.11 is default)
RUN cd $CACHE \
&& sh cmake-${CMAKE_VERSION}.${CMAKE_PATCH}-Linux-x86_64.sh --prefix=/usr --exclude-subdir

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Our manual shows full [read & write examples](https://openpmd-api.readthedocs.io
## Dependencies

Required:
* CMake 3.10.0+
* CMake 3.11.0+
* C++11 capable compiler, e.g. g++ 4.8+, clang 3.9+, VS 2015+

Shipped internally in `share/openPMD/thirdParty/`:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/dev/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ These are currently:
Required
--------

* CMake 3.10.0+
* CMake 3.11.0+
* C++11 capable compiler, e.g. g++ 4.8+, clang 3.9+, VS 2015+

Shipped internally
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake>=3.10.0,<4.0.0
cmake>=3.11.0,<4.0.0
pybind11>=2.2.3,<3.0.0
numpy>=1.15.0,<2.0.0
setuptools>=38.6
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ def run(self):
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError(
"CMake 3.10.0+ must be installed to build the following " +
"CMake 3.11.0+ must be installed to build the following " +
"extensions: " +
", ".join(e.name for e in self.extensions))

cmake_version = LooseVersion(re.search(
r'version\s*([\d.]+)',
out.decode()
).group(1))
if cmake_version < '3.10.0':
raise RuntimeError("CMake >= 3.10.0 is required")
if cmake_version < '3.11.0':
raise RuntimeError("CMake >= 3.11.0 is required")

for ext in self.extensions:
self.build_extension(ext)
Expand Down

0 comments on commit d5f5175

Please sign in to comment.