Skip to content

Commit 0664b57

Browse files
robertodrarnfinn
authored andcommitted
Mixed fixes for Conda build (#158)
* List ZLIB::ZLIB as PUBLIC * Update minimum required CMake version to 3.3 - Update Autocmake and remove in-house options_wrappers module * Use target_sources to build library * Use target_sources to build unit_tests executable * Deprecate C++03, simplify C++11 detection in CMake - Support for GCC 4.6 has officially been dropped. - Update CHANGELOG.md and README.md * Appease MinazoBot
1 parent dfda032 commit 0664b57

File tree

69 files changed

+539
-1321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+539
-1321
lines changed

.travis.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ matrix:
3030
- cmake3-data
3131
- clang
3232
- clang-format-3.9
33-
- gfortran-4.6
33+
- gfortran
3434
- libboost-math-dev
3535
env:
3636
- CXX_COMPILER='clang++'
3737
- C_COMPILER='clang'
38-
- Fortran_COMPILER='gfortran-4.6'
38+
- Fortran_COMPILER='gfortran'
3939
- BUILD_TYPE='release'
4040
- PYTHON='--three'
4141
- RUN_DANGER=true
@@ -45,14 +45,14 @@ matrix:
4545
packages:
4646
- cmake3
4747
- cmake3-data
48-
- g++-4.6
49-
- gcc-4.6
50-
- gfortran-4.6
48+
- g++
49+
- gcc
50+
- gfortran
5151
- libboost-math-dev
5252
env:
53-
- CXX_COMPILER='g++-4.6'
54-
- C_COMPILER='gcc-4.6'
55-
- Fortran_COMPILER='gfortran-4.6'
53+
- CXX_COMPILER='g++'
54+
- C_COMPILER='gcc'
55+
- Fortran_COMPILER='gfortran'
5656
- BUILD_TYPE='release'
5757
- PYTHON='--two'
5858
- RUN_DANGER=false
@@ -82,15 +82,15 @@ matrix:
8282
packages:
8383
- cmake3
8484
- cmake3-data
85-
- g++-4.8
86-
- gcc-4.8
87-
- gfortran-4.8
85+
- g++
86+
- gcc
87+
- gfortran
8888
- libboost-math-dev
8989
- lcov
9090
env:
91-
- CXX_COMPILER='g++-4.8'
92-
- C_COMPILER='gcc-4.8'
93-
- Fortran_COMPILER='gfortran-4.8'
91+
- CXX_COMPILER='g++'
92+
- C_COMPILER='gcc'
93+
- Fortran_COMPILER='gfortran'
9494
- BUILD_TYPE='debug'
9595
- PYTHON='--two'
9696
- COVERAGE='--coverage'

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
Messina (J. Chem. Phys. 2002, 117 (24), 11062) and
1010
Delgado _et al._ (J. Chem. Phys. 2013, 139 (2), 024105)
1111

12+
### Deprecated
13+
14+
- C++03 support is effectively **deprecated** in favor of C++11. Support for GCC
15+
4.6 and earlier has been dropped. Please consider upgrading your C++ compiler
16+
to a [fully standard-compliant one](https://en.cppreference.com/w/cpp/compiler_support#cpp11)
17+
1218
### Changed
1319

1420
- The versioning machinery has been updated. The update was inspired by the
@@ -31,6 +37,7 @@
3137
- The `ENABLE_Fortran_API` configuration option has been renamed
3238
`TEST_Fortran_API`, since it now only triggers compilation of the
3339
`Fortran_host` test case.
40+
- **BREAKING CHANGE** The minimum required version of CMake is now 3.3
3441

3542
### Fixed
3643

CMakeLists.txt

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Copyright (c) 2015-2018 by Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors.
33

44
# set minimum cmake version
5-
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
5+
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
66

77
# project name
8-
project(PCMSolver CXX C Fortran)
8+
project(PCMSolver LANGUAGES CXX C Fortran)
99

1010
# do not rebuild if rules (compiler flags) change
1111
set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
@@ -15,10 +15,44 @@ if(NOT CMAKE_BUILD_TYPE)
1515
set(CMAKE_BUILD_TYPE "Debug")
1616
endif()
1717

18+
# Options handling utilities
19+
include(CMakeDependentOption)
20+
# Macro for printing an option in a consistent manner
21+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
22+
# Syntax: print_option(<option to print> <was specified>)
23+
macro(print_option variable default)
24+
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
25+
message(STATUS "Setting (unspecified) option ${variable}: ${default}")
26+
else()
27+
message(STATUS "Setting option ${variable}: ${${variable}}")
28+
endif()
29+
endmacro()
30+
31+
# Wraps an option with default ON/OFF. Adds nice messaging to option()
32+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
33+
# Syntax: option_with_print(<option name> <description> <default value>)
34+
macro(option_with_print variable msge default)
35+
print_option(${variable} ${default})
36+
option(${variable} ${msge} ${default})
37+
endmacro()
38+
39+
# Wraps an option with a default other than ON/OFF and prints it
40+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
41+
# NOTE: Can't combine with above b/c CMake handles ON/OFF options specially
42+
# NOTE2: CMake variables are always defined so need to further check for if
43+
# they are the NULL string. This is also why we need the force
44+
# Syntax: option_with_default(<option name> <description> <default value>)
45+
macro(option_with_default variable msge default)
46+
print_option(${variable} "${default}")
47+
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
48+
set(${variable} "${default}" CACHE STRING ${msge} FORCE)
49+
endif()
50+
endmacro()
51+
1852
# directories which hold included cmake modules
19-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/custom)
20-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/custom/compilers)
21-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/downloaded)
53+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/custom)
54+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/custom/compilers)
55+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/downloaded)
2256

2357
# included cmake modules
2458
include(autocmake_fc)
@@ -28,7 +62,6 @@ include(Fortran_C)
2862
include(CXXFlags)
2963
include(CFlags)
3064
include(FortranFlags)
31-
include(options_wrappers)
3265
include(autocmake_custom_color_messages)
3366
include(autocmake_ccache)
3467
include(windows)

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
[![Travis CI build status](https://travis-ci.org/PCMSolver/pcmsolver.svg?branch=release%2F1.2.Z)](https://travis-ci.org/PCMSolver/pcmsolver)
33
[![Documentation Status](https://readthedocs.org/projects/pcmsolver/badge/?version=stable)](http://pcmsolver.readthedocs.org/en/latest/?badge=latest)
44
[![Coverage Status](https://codecov.io/gh/PCMSolver/pcmsolver/branch/release%2F1.2.Z/graph/badge.svg)](https://codecov.io/gh/PCMSolver/pcmsolver)
5-
[![Coverity Scan Build](https://scan.coverity.com/projects/3046/badge.svg)](https://scan.coverity.com/projects/3046)
65

76
PCMSolver
87
=========
@@ -29,17 +28,11 @@ Python and Python packages are installed and managed _via_ [Pipenv](http://pipen
2928
using the `Pipfile` and `Pipfile.lock` files. The following
3029
compilers are used:
3130

32-
1. GCC 4.6, Python 2.7 This build generates _both_ the shared and static
31+
1. GCC 4.8, Python 2.7 This build generates _both_ the shared and static
3332
libraries, linking executables to the former.
3433
2. GCC 6.3.0, Python 2.7 This build generates _only_ the static library.
35-
3. Clang 3.5, GFortran 4.6, Python 3.5 This build generates _both_ the shared and static
34+
3. Clang 3.5, GFortran 4.8, Python 3.5 This build generates _both_ the shared and static
3635
libraries, linking executables to the former.
3736
4. GCC 4.8, Python 2.7 This is a _debug_ build generating _both_ the shared and static
3837
libraries, linking executables to the former. The build is run with
3938
coverage analysis for submission to [Codecov](https://codecov.io).
40-
41-
The build needed for submission to [Coverity scan](https://scan.coverity.com/)
42-
is triggered by pushes to the `coverity_scan` branch. It is run on
43-
Ubuntu 12.04 LTS 64-bit with Python 2.7, CMake 3.3.2 and Boost 1.55.0
44-
this is the environment offered by [Travis CI](https://travis-ci.org) pulling
45-
in various PPA. GCC 5.1 is used, in debug mode.

cmake/autocmake.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: PCMSolver
2-
min_cmake_version: 2.8.10
2+
min_cmake_version: 3.3
33
setup_script: setup.py
44
url_root: https://github.com/coderefinery/autocmake/raw/master/
55
default_build_type: debug
@@ -22,7 +22,6 @@ modules:
2222
- 'custom/compilers/FortranFlags.cmake'
2323
- plugins:
2424
- source:
25-
- 'custom/options_wrappers.cmake'
2625
- '%(url_root)modules/custom_color_messages.cmake'
2726
- '%(url_root)modules/ccache.cmake'
2827
- 'custom/windows.cmake'

cmake/autocmake/generate.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,43 @@ def autogenerated_notice():
4545
return '\n'.join(s)
4646

4747

48+
def gen_cmake_options_wrappers():
49+
s = """\n# Options handling utilities
50+
include(CMakeDependentOption)
51+
# Macro for printing an option in a consistent manner
52+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
53+
# Syntax: print_option(<option to print> <was specified>)
54+
macro(print_option variable default)
55+
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
56+
message(STATUS "Setting (unspecified) option ${variable}: ${default}")
57+
else()
58+
message(STATUS "Setting option ${variable}: ${${variable}}")
59+
endif()
60+
endmacro()
61+
62+
# Wraps an option with default ON/OFF. Adds nice messaging to option()
63+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
64+
# Syntax: option_with_print(<option name> <description> <default value>)
65+
macro(option_with_print variable msge default)
66+
print_option(${variable} ${default})
67+
option(${variable} ${msge} ${default})
68+
endmacro()
69+
70+
# Wraps an option with a default other than ON/OFF and prints it
71+
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
72+
# NOTE: Can't combine with above b/c CMake handles ON/OFF options specially
73+
# NOTE2: CMake variables are always defined so need to further check for if
74+
# they are the NULL string. This is also why we need the force
75+
# Syntax: option_with_default(<option name> <description> <default value>)
76+
macro(option_with_default variable msge default)
77+
print_option(${variable} "${default}")
78+
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
79+
set(${variable} "${default}" CACHE STRING ${msge} FORCE)
80+
endif()
81+
endmacro()"""
82+
return s
83+
84+
4885
def gen_setup(config, default_build_type, relative_path, setup_script_name):
4986
"""
5087
Generate setup script.
@@ -132,7 +169,7 @@ def gen_cmakelists(project_name, project_language, min_cmake_version, default_bu
132169
s.append('cmake_minimum_required(VERSION {0} FATAL_ERROR)'.format(min_cmake_version))
133170

134171
s.append('\n# project name')
135-
s.append('project({0} {1})'.format(project_name, project_language))
172+
s.append('project({0} LANGUAGES {1})'.format(project_name, project_language))
136173

137174
s.append('\n# do not rebuild if rules (compiler flags) change')
138175
s.append('set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)')
@@ -148,6 +185,8 @@ def gen_cmakelists(project_name, project_language, min_cmake_version, default_bu
148185
s.append(' set(CMAKE_BUILD_TYPE "{0}")'.format(_build_type))
149186
s.append('endif()')
150187

188+
s.append(gen_cmake_options_wrappers())
189+
151190
if len(modules) > 0:
152191
s.append('\n# directories which hold included cmake modules')
153192

@@ -159,7 +198,7 @@ def gen_cmakelists(project_name, project_language, min_cmake_version, default_bu
159198
rel_cmake_module_path = os.path.join(relative_path, directory)
160199
# on windows cmake corrects this so we have to make it wrong again
161200
rel_cmake_module_path = rel_cmake_module_path.replace('\\', '/')
162-
s.append('set(CMAKE_MODULE_PATH ${{CMAKE_MODULE_PATH}} ${{PROJECT_SOURCE_DIR}}/{0})'.format(rel_cmake_module_path))
201+
s.append('list(APPEND CMAKE_MODULE_PATH ${{PROJECT_SOURCE_DIR}}/{0})'.format(rel_cmake_module_path))
163202

164203
if len(modules) > 0:
165204
s.append('\n# included cmake modules')

cmake/custom/compilers/CXXFlags.cmake

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
option(ENABLE_CXX11_SUPPORT "Enable C++11 compiler support" ON)
1+
option_with_print(ENABLE_CXX11_SUPPORT "Enable C++11 compiler support" ON)
2+
3+
# Discover C++11 support
4+
if(ENABLE_CXX11_SUPPORT)
5+
include(SetCompilerFlag)
6+
set_compiler_flag(
7+
RESULT cxx11_flag
8+
LANGUAGE CXX
9+
REQUIRED
10+
FLAGS "-std=c++11;-std=c++0x;--c++11;--c++0x"
11+
)
12+
if(cxx11_flag)
13+
set(CXX_STANDARD_FLAG ${cxx11_flag})
14+
set(HAS_CXX11 TRUE)
15+
message(STATUS "Using C++11 standard")
16+
else()
17+
set(CXX_STANDARD_FLAG "-std=gnu++98")
18+
set(HAS_CXX11 FALSE)
19+
message(STATUS "Using C++03 standard")
20+
message(WARNING "Upgrade your compiler! C++03 support is DEPRECATED and will be removed")
21+
endif()
22+
else()
23+
message(WARNING "Upgrade your compiler! C++03 support is DEPRECATED and will be removed")
24+
endif()
225

326
include(GNU.CXX)
427
include(Clang.CXX)

0 commit comments

Comments
 (0)