Skip to content

Commit 3ce437c

Browse files
robertodrilfreddy
authored andcommitted
Fix visibility of symbols and RPATH
1 parent d4f274f commit 3ce437c

30 files changed

+246
-179
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Change Log
22

3+
## [Unreleased]
4+
5+
### Added
6+
7+
- A new CMake module `options_wrappers.cmake` that adds new wrapper macros for
8+
the CMake `option` command.
9+
10+
### Fixed
11+
12+
- Visibility of symbols in the shared library is _finally_ handled properly.
13+
The necessary flags to the C++ compiler were not set for the subtargets built
14+
as CMake `OBJECT` libraries. This results in a modest decrease in library
15+
size.
16+
- `RPATH` handling for the standalone executable `run_pcm`.
17+
For the executable in `<build_dir>/bin` the `RPATH` will contain
18+
`<build_dir>/lib64` (or `<build_dir>/lib`) as path to `libpcm.so.1`.
19+
For the executable in `<install_prefix>/bin` the `RPATH` will contain
20+
`<install_prefix>/lib64` (or `<install_prefix>/lib`) as path to `libpcm.so.1`.
21+
22+
### Changed
23+
24+
- As a result of the visibility change, unit tests can only be linked against
25+
the static library, since all symbols are always visible in a static archive
26+
library.
27+
328
## [Version 1.1.12] - 2018-01-20
429

530
### Added

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file is autogenerated by Autocmake v1.0.0-alpha-x http://autocmake.org
2-
# Copyright (c) 2015-2017 by Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors.
2+
# Copyright (c) 2015-2018 by Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors.
33

44
# set minimum cmake version
55
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
@@ -28,10 +28,9 @@ include(Fortran_C)
2828
include(CXXFlags)
2929
include(CFlags)
3030
include(FortranFlags)
31+
include(options_wrappers)
3132
include(autocmake_custom_color_messages)
32-
include(GNUdirs)
3333
include(autocmake_ccache)
34-
include(rpath)
3534
include(windows)
3635
include(autocmake_definitions)
3736
include(autocmake_code_coverage)

cmake/autocmake.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ modules:
2222
- 'custom/compilers/FortranFlags.cmake'
2323
- plugins:
2424
- source:
25+
- 'custom/options_wrappers.cmake'
2526
- '%(url_root)modules/custom_color_messages.cmake'
26-
- 'custom/GNUdirs.cmake'
2727
- '%(url_root)modules/ccache.cmake'
28-
- 'custom/rpath.cmake'
2928
- 'custom/windows.cmake'
3029
- '%(url_root)modules/definitions.cmake'
3130
- '%(url_root)modules/code_coverage.cmake'

cmake/custom/FindRT.cmake

Lines changed: 0 additions & 39 deletions
This file was deleted.

cmake/custom/GNUdirs.cmake

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Options handling utilities
2+
include(CMakeDependentOption)
3+
# Macro for printing an option in a consistent manner
4+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
5+
# Syntax: print_option(<option to print> <was specified>)
6+
macro(print_option variable default)
7+
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
8+
message(STATUS "Setting (unspecified) option ${variable}: ${default}")
9+
else()
10+
message(STATUS "Setting option ${variable}: ${${variable}}")
11+
endif()
12+
endmacro()
13+
14+
# Wraps an option with default ON/OFF. Adds nice messaging to option()
15+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
16+
# Syntax: option_with_print(<option name> <description> <default value>)
17+
macro(option_with_print variable msge default)
18+
print_option(${variable} ${default})
19+
option(${variable} ${msge} ${default})
20+
endmacro(option_with_print)
21+
22+
# Wraps an option with a default other than ON/OFF and prints it
23+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
24+
# NOTE: Can\'t combine with above b/c CMake handles ON/OFF options specially
25+
# NOTE2: CMake variables are always defined so need to further check for if
26+
# they are the NULL string. This is also why weneed the force
27+
# Syntax: option_with_default(<option name> <description> <default value>)
28+
macro(option_with_default variable msge default)
29+
print_option(${variable} "${default}")
30+
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
31+
set(${variable} "${default}" CACHE STRING ${msge} FORCE)
32+
endif()
33+
endmacro(option_with_default)

cmake/custom/pcmsolver.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ endif()
1313
set(BOOST_MINIMUM_REQUIRED 1.54.0)
1414
set(BOOST_COMPONENTS_REQUIRED "")
1515

16-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
17-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
16+
include(GNUInstallDirs)
17+
18+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
19+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
20+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
1821

1922
include_directories(${PROJECT_SOURCE_DIR}/include)
2023
add_subdirectory(${PROJECT_SOURCE_DIR}/include)

cmake/custom/rpath.cmake

Lines changed: 0 additions & 5 deletions
This file was deleted.

cmake/custom/static_library.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#.rst:
22
#
3-
# Enables creation of static library.
3+
# Enables creation of static/shared library.
44
# If the shared library is created, make it as static as possible.
55
#
66
# Variables modified (provided the corresponding language is enabled)::
@@ -15,6 +15,7 @@
1515
# define: "'-DSTATIC_LIBRARY_ONLY={0}'.format(arguments['--static'])"
1616

1717
option(STATIC_LIBRARY_ONLY "Create the static library only" OFF)
18+
option(SHARED_LIBRARY_ONLY "Create the shared library only" OFF)
1819
option(ENABLE_GENERIC "Enable mostly static linking in shared library" OFF)
1920

2021
if(ENABLE_GENERIC)

cmake/custom/test.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
option(ENABLE_TESTS "Enable PCMSolver unit tests" ON)
1+
# Unit tests need to be linked to the static version of the library
2+
cmake_dependent_option(ENABLE_TESTS "Enable PCMSolver unit tests" ON
3+
"NOT SHARED_LIBRARY_ONLY" OFF)
24

35
macro(add_Catch_test _name _labels)
46
# _labels is not a list, it's a string... Transform it into a list
@@ -10,7 +12,7 @@ macro(add_Catch_test _name _labels)
1012
unset(_labels)
1113

1214
add_test(NAME ${_name}
13-
COMMAND ${PROJECT_BINARY_DIR}/tests/unit_tests [${_name}] --success --out ${PROJECT_BINARY_DIR}/tests/${_name}.log --durations yes
15+
COMMAND unit_tests [${_name}] --success --out ${PROJECT_BINARY_DIR}/tests/${_name}.log --durations yes
1416
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
1517

1618
if(labels)

0 commit comments

Comments
 (0)