Skip to content

Commit f99a710

Browse files
author
Roberto Di Remigio
committed
Fix builds on Magnum CI + Eigen3 issues + RPATH issues
1. Builds on Magnum CI are finally working again 2. Users can choose their own Eigen3 installation 3. The run_pcm executable has an RPATH that points to both the install tree and the build tree. Other executables that are not installed (update_reference_files and unit_tests) have an RPATH that points to the build tree.
1 parent 9dba357 commit f99a710

File tree

31 files changed

+140
-134
lines changed

31 files changed

+140
-134
lines changed

.magnum.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ language: cpp
22
git:
33
submodules: false
44
before_install:
5-
- sudo apt-get update -y
6-
- sudo apt-get install gcc g++ gfortran make cmake cmake-data zlib1g-dev python-dateutil python-pyparsing python-numpy python-matplotlib python-pip python-setuptools python-dev -y
7-
- cmake --version
8-
- gcc --version
9-
- g++ --version
10-
- gfortran --version
11-
- python --version
5+
- DEPS_DIR="${HOME}/deps"
6+
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
7+
- sudo apt-get update -y
8+
- sudo apt-get install -y gcc g++ gfortran make zlib1g-dev python-dev
9+
- mkdir ${DEPS_DIR}/cmake
10+
- wget --no-check-certificate https://cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.tar.gz
11+
- tar --strip-components=1 -xzf cmake-3.4.3-Linux-x86_64.tar.gz -C cmake
12+
- export PATH=${DEPS_DIR}/cmake/bin:$PATH
13+
- cd -
14+
- cmake --version
15+
- gcc --version
16+
- g++ --version
17+
- gfortran --version
18+
- python --version
1219
script:
1320
- python setup.py --cxx=g++ --cc=gcc --fc=gfortran --type=debug --cmake-options='-Hprojects/CMake -DENABLE_FORTRAN_API=ON'
1421
- cd build

cmake/custom/api.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ install(FILES ${PROJECT_SOURCE_DIR}/api/PCMInput.h DESTINATION include)
55

66
if(ENABLE_FORTRAN_API)
77
add_definitions(-DENABLE_FORTRAN_API)
8-
set_property(GLOBAL APPEND PROPERTY PCMSolver_Fortran_SOURCES ${PROJECT_SOURCE_DIR}/api/pcmsolver.F90)
8+
add_library(fortran_bindings OBJECT ${PROJECT_SOURCE_DIR}/api/pcmsolver.F90)
99
endif()

cmake/custom/eigen.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define: '-DEIGEN3_ROOT="{0}"'.format(arguments['--eigen'])
1212

1313
if(EIGEN3_ROOT)
14-
set(EIGEN3_INCLUDE_DIR ${EIGEN3_ROOT}/include/eigen3)
14+
set(EIGEN3_INCLUDE_DIR ${EIGEN3_ROOT}/include)
1515
find_package(Eigen3 3.1.0)
1616
message(STATUS "Eigen " ${EIGEN3_VERSION} " is located here: " ${EIGEN3_INCLUDE_DIR})
1717
if(NOT EIGEN3_FOUND)

cmake/custom/pcmsolver.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ set(BOOST_COMPONENTS_REQUIRED "")
2323
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
2424
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
2525

26-
# PCMSolver C++ sources
27-
set_property(GLOBAL PROPERTY PCMSolver_CXX_SOURCES)
28-
# PCMSolver C sources
29-
set_property(GLOBAL PROPERTY PCMSolver_C_SOURCES)
30-
# PCMSolver Fortran sources
31-
set_property(GLOBAL PROPERTY PCMSolver_Fortran_SOURCES)
32-
# PCMSolver headers
26+
# PCMSolver header directories
3327
set_property(GLOBAL PROPERTY PCMSolver_HEADER_DIRS)
3428

3529
include_directories(${PROJECT_BINARY_DIR}/include)

cmake/custom/rpath.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ if(APPLE)
22
if(NOT DEFINED CMAKE_MACOSX_RPATH)
33
set(CMAKE_MACOSX_RPATH ON)
44
# Mark as undefined symbols that have to be defined by the host
5-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-U,_host_writer")
5+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-U,_host_writer")
66
endif()
77
endif()

cmake/custom/test.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ macro(add_Catch_test _name _labels)
1010
unset(_labels)
1111

1212
# This is the unit tests runner
13-
set(RUNNER ${PROJECT_BINARY_DIR}/tests/unit_tests${EXE})
13+
set(RUNNER ${PROJECT_BINARY_DIR}/tests/unit_tests)
1414

1515
add_test(NAME ${_name} COMMAND ${RUNNER} [${_name}])
1616

doc/programmers/cmake-usage.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is a brief guide to our CMake infrastructure which is managed
66

77
.. warning::
88

9-
The minimum required CMake version is 2.8.3
9+
The minimum required CMake version is 2.8.8
1010

1111
Adding new source subdirectories and/or files
1212
---------------------------------------------
@@ -66,10 +66,9 @@ to generate a template ``CMakeLists.txt.try`` file:
6666
# List of sources
6767
list(APPEND sources_list Cavity.cpp Element.cpp GePolCavity.cpp RestartCavity.cpp)
6868
69+
add_library(cavity OBJECT ${sources_list} ${headers_list})
70+
set_target_properties(cavity PROPERTIES POSITION_INDEPENDENT_CODE 1 INTERPROCEDURAL_OPTIMIZATION 1)
6971
set_property(GLOBAL APPEND PROPERTY PCMSolver_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
70-
foreach(_source ${sources_list})
71-
set_property(GLOBAL APPEND PROPERTY PCMSolver_CXX_SOURCES ${CMAKE_CURRENT_LIST_DIR}/${_source})
72-
endforeach()
7372
# Sets install directory for all the headers in the list
7473
foreach(_header ${headers_list})
7574
install(FILES ${_header} DESTINATION include/cavity)
@@ -83,7 +82,8 @@ hierarchy and it contains set of instructions for:
8382
hierarchy, possibly excluding some of them
8483
#. define install targets for the files in this subdirectory.
8584

86-
All the source files are compiled into a unique static library ``libpcm.a``.
85+
All the source files are compiled into the unique static library ``libpcm.a`` and unique
86+
dynamic library ``libpcm.so``.
8787
This library is the one the host QM program need to link.
8888

8989
Searching for libraries

doc/users/building.rst

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ the unit test suite.
2828
Libraries and toolchain programs
2929
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3030

31-
+ CMake version 2.8.3 and higher;
31+
+ CMake version 2.8.8 and higher;
3232
+ Git version 1.7.1 and higher;
3333
+ Python interpreter 2.4 and higher;
3434
+ Boost libraries version 1.54.0 and higher;
@@ -121,18 +121,40 @@ or with:
121121
Advanced configuration options
122122
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123123

124-
As of version 3.1.0 Eigen can fall back to certain BLAS/LAPACK routines as
125-
implemented in Intel's Math Kernel Library (MKL). You can enable this feature
126-
passing the option `-DENABLE_EIGEN_MKL=ON` to the setup script. You need at least
127-
version 10.3 of Intel MKL. Be sure to have read
128-
the relevant `guide <http://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html>`_
124+
These options are marked as advanced as it is highly unlikely they will
125+
be useful when not programming the library:
129126

130-
.. warning::
127+
* `--exdiag` Enable C++ extended diagnostics flags. Disabled by default.
128+
* `--ccache` Enable use of ccache for C/C++ compilation caching.
129+
Enabled by default, unless ccache is not available.
130+
* `--build-boost` Deactivate Boost detection and build on-the-fly. Disabled by default.
131+
* `--eigen` Root directory for Eigen3. Search for Eigen3 in the location provided by the
132+
user. If search fails, fall back to the version bundled with the library.
133+
* `--static` Create only static library. Disabled by default.
131134

132-
By itself, the module **does not** need to link to any mathematical
133-
library. This option makes sense only when linking the module to a QM program
134-
that links to Intel MKL. **Use at your own risk!** There is no proof that
135-
enabling this option leads to significant speedups!
135+
Some options can only be tweaked `via` `--cmake-options` to the setup script:
136+
137+
* `ENABLE_CXX11_SUPPORT` Enable C++11 support. Tries to detect which C++11 features
138+
are supported by the compiler and enables use of the new standard. Enabled by default.
139+
140+
.. warning::
141+
142+
This option is **always** overridden for some compilers that have
143+
buggy C++11 support.
144+
145+
* `ENABLE_DOCS` Enable build of documentation. This requires a number of additional dependencies.
146+
If any of these are not met, documentation is not built. Enabled by default.
147+
* `ENABLE_LOGGER` Enable compilation of logger sources. Disabled by default.
148+
149+
.. warning::
150+
151+
The logger is not currently in use in any part of the code.
152+
153+
* `ENABLE_TIMER` Enable compilation of timer sources. Enabled by default.
154+
* `BUILD_STANDALONE` Enable compilation of standalone `run_pcm` executable. Enabled by default.
155+
* `ENABLE_FORTRAN_API` Enable compilation of the Fortran90 bindings for the API. Disabled by default.
156+
* `ENABLE_GENERIC` Enable mostly static linking in shared library. Disabled by default.
157+
* `ENABLE_TESTS` Enable compilation of unit tests suite. Enabled by default.
136158

137159
Build and test
138160
--------------

src/CMakeLists.txt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,35 @@ add_subdirectory(pedra)
1717
add_subdirectory(solver)
1818
add_subdirectory(utils)
1919

20-
get_property(_pcmsolver_cxx_sources GLOBAL PROPERTY PCMSolver_CXX_SOURCES)
21-
get_property(_pcmsolver_c_sources GLOBAL PROPERTY PCMSolver_C_SOURCES)
22-
get_property(_pcmsolver_fortran_sources GLOBAL PROPERTY PCMSolver_Fortran_SOURCES)
23-
add_library(pcm-base OBJECT ${_pcmsolver_cxx_sources} ${_pcmsolver_c_sources} ${_pcmsolver_fortran_sources})
24-
if(BUILD_CUSTOM_BOOST)
25-
add_dependencies(pcm-base custom_boost)
26-
endif()
20+
list(APPEND _objects $<TARGET_OBJECTS:cavity>
21+
$<TARGET_OBJECTS:green>
22+
$<TARGET_OBJECTS:interface>
23+
$<TARGET_OBJECTS:metal>
24+
$<TARGET_OBJECTS:bi_operators>
25+
$<TARGET_OBJECTS:pedra>
26+
$<TARGET_OBJECTS:solver>
27+
$<TARGET_OBJECTS:utils>
28+
$<TARGET_OBJECTS:getkw>
29+
$<TARGET_OBJECTS:fortran_bindings>
30+
)
2731
if(NOT STATIC_LIBRARY_ONLY)
28-
set_target_properties(pcm-base PROPERTIES POSITION_INDEPENDENT_CODE 1
29-
INTERPROCEDURAL_OPTIMIZATION 1)
30-
add_library(pcm-shared SHARED $<TARGET_OBJECTS:pcm-base> $<TARGET_OBJECTS:getkw>)
32+
add_library(pcm-shared SHARED "${_objects}")
3133
target_link_libraries(pcm-shared ${ZLIB_LIBRARIES} ${LIBC_INTERJECT})
3234
set_target_properties(pcm-shared PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} CLEAN_DIRECT_OUTPUT 1 OUTPUT_NAME "pcm")
3335
install(TARGETS pcm-shared DESTINATION lib)
36+
if(BUILD_CUSTOM_BOOST)
37+
add_dependencies(pcm-shared custom_boost)
38+
endif()
3439
endif()
3540

36-
add_library(pcm-static STATIC $<TARGET_OBJECTS:pcm-base> $<TARGET_OBJECTS:getkw>)
41+
add_library(pcm-static STATIC "${_objects}")
3742
set_target_properties(pcm-static PROPERTIES CLEAN_DIRECT_OUTPUT 1 OUTPUT_NAME "pcm")
3843
install(TARGETS pcm-static ARCHIVE DESTINATION lib)
3944

45+
if(BUILD_CUSTOM_BOOST)
46+
add_dependencies(pcm-static custom_boost)
47+
endif()
48+
4049
# This directory contains source file for executables
4150
if(BUILD_STANDALONE)
4251
add_subdirectory(bin)

src/bi_operators/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ list(APPEND headers_list CollocationIntegrator.hpp IntegratorForward.hpp Integra
44
# List of sources
55
list(APPEND sources_list )
66

7+
add_library(bi_operators OBJECT ${headers_list} ${sources_list})
8+
set_target_properties(bi_operators PROPERTIES POSITION_INDEPENDENT_CODE 1 INTERPROCEDURAL_OPTIMIZATION 1)
79
set_property(GLOBAL APPEND PROPERTY PCMSolver_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
8-
foreach(_source ${sources_list})
9-
set_property(GLOBAL APPEND PROPERTY PCMSolver_CXX_SOURCES ${CMAKE_CURRENT_LIST_DIR}/${_source})
10-
endforeach()
1110
# Sets install directory for all the headers in the list
1211
foreach(_header ${headers_list})
1312
install(FILES ${_header} DESTINATION include/bi_operators)

0 commit comments

Comments
 (0)