Skip to content
Snippets Groups Projects
Commit ab37cf64 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Merge branch 'update-cmake' into 'develop'

Require at least CMake 3.16 and clang-10

See merge request !129
parents be8df395 9a92e25e
No related branches found
No related tags found
1 merge request!129Require at least CMake 3.16 and clang-10
cmake_minimum_required (VERSION 3.10) cmake_minimum_required (VERSION 3.16)
# CMake utils # CMake utils
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
...@@ -22,6 +22,9 @@ if("${PUGS_SHORT_VERSION}" STREQUAL "") ...@@ -22,6 +22,9 @@ if("${PUGS_SHORT_VERSION}" STREQUAL "")
message(FATAL_ERROR "Unable to compute short version from PUGS_VERSION=${PUGS_VERSION}") message(FATAL_ERROR "Unable to compute short version from PUGS_VERSION=${PUGS_VERSION}")
endif() endif()
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;Coverage" CACHE STRING INTERNAL FORCE )
# set project version as PUGS_SHORT_VERSION # set project version as PUGS_SHORT_VERSION
project (Pugs VERSION ${PUGS_SHORT_VERSION}) project (Pugs VERSION ${PUGS_SHORT_VERSION})
...@@ -34,16 +37,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ...@@ -34,16 +37,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(PUGS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(PUGS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(PUGS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(PUGS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# Change RelWithDebInfo to compile assertions
SET("CMAKE_CXX_FLAGS_RELWITHDEBINFO"
"-g -O2"
CACHE STRING "Flags used by the compiler during release builds with debug info and assertions"
FORCE )
SET("CMAKE_C_FLAGS_RELWITHDEBINFO"
"-g -O2"
CACHE STRING "Flags used by the compiler during release builds with debug info and assertions"
FORCE )
# Add new build types # Add new build types
set(CMAKE_CXX_FLAGS_COVERAGE set(CMAKE_CXX_FLAGS_COVERAGE
"-g -O0 --coverage" "-g -O0 --coverage"
...@@ -68,16 +61,16 @@ mark_as_advanced( ...@@ -68,16 +61,16 @@ mark_as_advanced(
CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
if(CMAKE_BUILD_TYPE) if(CMAKE_BUILD_TYPE)
string(REGEX MATCH "(Debug|Release|RelWithDebInfo|MinSizeRel|Coverage)" VALID_BUILD_TYPE "${CMAKE_BUILD_TYPE}") string(REGEX MATCH "^(Release|Debug|Coverage)$" VALID_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
if(NOT VALID_BUILD_TYPE) if(NOT VALID_BUILD_TYPE)
message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}'") message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}'")
endif() endif()
endif() endif()
# Default build type is RelWIthDebInfo # Default build type is Release
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build: Debug Release RelWithDebInfo MinSizeRel Coverage." "Choose the type of build: Release Debug Coverage."
FORCE) FORCE)
endif() endif()
...@@ -90,8 +83,8 @@ endif() ...@@ -90,8 +83,8 @@ endif()
#------------------------------------------------------ #------------------------------------------------------
# Checks if compiler version is compatible with Pugs sources # Checks if compiler version is compatible with Pugs sources
set(GNU_CXX_MIN_VERSION "8.0.0") set(GNU_CXX_MIN_VERSION "9.0.0")
set(CLANG_CXX_MIN_VERSION "8.0.0") set(CLANG_CXX_MIN_VERSION "10.0.0")
# Pugs default compiler flags # Pugs default compiler flags
set(PUGS_CXX_FLAGS "${PUGS_CXX_FLAGS} -Wall -Wextra -pedantic") set(PUGS_CXX_FLAGS "${PUGS_CXX_FLAGS} -Wall -Wextra -pedantic")
...@@ -107,11 +100,11 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ...@@ -107,11 +100,11 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(PUGS_CXX_FLAGS "${PUGS_CXX_FLAGS} -Wsign-compare -Wunused -Wunused-member-function -Wunused-private-field") set(PUGS_CXX_FLAGS "${PUGS_CXX_FLAGS} -Wsign-compare -Wunused -Wunused-member-function -Wunused-private-field")
endif() endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0") # if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")
set(PUGS_STD_LINK_FLAGS "-lstdc++fs") # set(PUGS_STD_LINK_FLAGS "-lstdc++fs")
endif() # endif()
endif() # endif()
#------------------------------------------------------ #------------------------------------------------------
...@@ -327,12 +320,10 @@ endif() ...@@ -327,12 +320,10 @@ endif()
# Compiler flags # Compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PUGS_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PUGS_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${PUGS_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${PUGS_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${PUGS_CXX_FLAGS}")
# Add debug mode for Standard C++ library (not for AppleClang since it is broken) # Add debug mode for Standard C++ library (not for AppleClang since it is broken)
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -D_LIBCPP_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -D_LIBCPP_DEBUG=1")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -D_GLIBCXX_DEBUG -D_LIBCPP_DEBUG=1")
endif() endif()
#------------------------------------------------------ #------------------------------------------------------
...@@ -600,20 +591,29 @@ target_link_libraries( ...@@ -600,20 +591,29 @@ target_link_libraries(
include(PugsDoxygen) include(PugsDoxygen)
# ------------------- Installation -------------------- # ------------------- Installation --------------------
# temporary version workaround install(TARGETS
if(${CMAKE_VERSION} VERSION_LESS "3.13.0") pugs
install(TARGETS pugs PugsMesh
RUNTIME DESTINATION bin PugsAlgebra
LIBRARY DESTINATION lib PugsAnalysis
ARCHIVE DESTINATION lib) PugsUtils
else() PugsLanguage
install(TARGETS pugs PugsAlgebra PugsAnalysis PugsUtils PugsLanguage PugsLanguageAST PugsLanguageModules PugsLanguageAlgorithms PugsLanguageUtils PugsMesh PugsScheme PugsOutput PugsLanguageAST
PugsLanguageModules
PugsLanguageAlgorithms
PugsMesh
PugsAlgebra
PugsScheme
PugsUtils
PugsOutput
PugsLanguageUtils
kokkos
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib) ARCHIVE DESTINATION lib)
endif()
# ------------------- Build options -------------------
message("") message("")
message("====== pugs build options ======") message("====== pugs build options ======")
message(" version: ${PUGS_VERSION}") message(" version: ${PUGS_VERSION}")
......
...@@ -3,10 +3,16 @@ ...@@ -3,10 +3,16 @@
---- ----
## Branches ## Branches
`develop` and `master` branches are protected. This means that one cannot `push` on them, so **before** to do any code change one has to create a working branch. The following conventions are greatly encouraged: `develop` and `master` branches are protected. This means that one
cannot `push` on them, so **before** to do any code change one has to
create a working branch. The following conventions are greatly
encouraged:
* `feature/my_outstanding_feature` * `feature/my_outstanding_feature`
* `issue/issue-number` (if no number is related to the issue please consider [opening an issue](https://gitlab.delpinux.fr/code/pugs/issues) and assign it to yourself) * `issue/issue-number` (if no number is related to the issue please
consider [opening an
issue](https://gitlab.delpinux.fr/code/pugs/issues) and assign it to
yourself)
---- ----
## Tests and coverage ## Tests and coverage
...@@ -18,21 +24,24 @@ Tests are built automatically and are run typing ...@@ -18,21 +24,24 @@ Tests are built automatically and are run typing
**all tests should be running correctly before any merge request** **all tests should be running correctly before any merge request**
### Unit tests ### Unit tests
Unit tests are defined in the `tests` directory. New unit tests should be written or updated when needed. Unit tests are defined in the `tests` directory. New unit tests should
be written or updated when needed.
### Coverage ### Coverage
Preferably, one should install [gcovr](http://www.gcovr.com) and build `pugs` specifying the `Coverage` build type Preferably, one should install [gcovr](http://www.gcovr.com) and build
> `cmake -DCMAKE_BUILD_TYPE=Coverage [...]` `pugs` specifying the `Coverage` build type > `cmake
-DCMAKE_BUILD_TYPE=Coverage [...]`
However coverage is computed at each `push` by the `gitlab-ci`. However coverage is computed at each `push` by the `gitlab-ci`.
---- ----
## Update build environment using [Docker](http://www.docker.com) ## Up to date build environment using [Docker](http://www.docker.com)
This is the easiest way to keep your environment update to build `pugs`. This is the easiest way to keep your environment up to date in order
to build `pugs`.
Running the [docker-pugs.sh](tools/docker-pugs.sh) script creates the image and Running the [docker-pugs.sh](tools/docker-pugs.sh) script creates the
runs it in interactive mode. The image will runs the user's permissions and his image and runs it in interactive mode. The image will runs the user's
home directory is mounted. permissions and his home directory is mounted.
**keep in mind that the produced executable will only run inside docker** **keep in mind that the produced executable will only run inside docker**
...@@ -40,21 +49,26 @@ home directory is mounted. ...@@ -40,21 +49,26 @@ home directory is mounted.
## Coding ## Coding
### `packages` directory ### `packages` directory
Do not make **any** change in the `packages` directory. This directory contains *third party libraries* that are are mandatory to minimal builds or `pugs`. Do not make **any** change in the `packages` directory. This directory
contains *third party libraries* that are are mandatory to minimal
builds or `pugs`.
For any changes in this directory For any changes in this directory (bug report, suggestion of new
(bug report, suggestion of new library, library upgrades or downgrades) **open an issue**. library, library upgrades or downgrades) **open an issue**.
### Warnings ### Warnings
Try to avoid publishing sources that generates compilation warnings. Try to avoid publishing sources that generates compilation warnings.
Also, avoid the use of `#warning` directives and prefer opening an issue. Also, avoid the use of `#warning` directives and prefer opening an
issue.
`C++` `[[deprecated]]` directive should also be avoid as much as possible. `C++` `[[deprecated]]` directive should also be avoid as much as
possible.
### Comments ### Comments
**Do not** comment deprecated code. It is `git`'s job to keep track of old versions. **Do not** comment deprecated code. It is `git`'s job to keep track of
old versions.
Avoid commenting functions bodies: Avoid commenting functions bodies:
...@@ -68,7 +82,10 @@ Avoid commenting functions bodies: ...@@ -68,7 +82,10 @@ Avoid commenting functions bodies:
`clang-format` is used in `pugs`, so install it and run `clang-format` is used in `pugs`, so install it and run
> `make clang-format` before any commit > `make clang-format` before any commit
A better solution is to configure your favored editor to perform formatting automatically. For instance `emacs` users should copy-past the following code to their `.emacs.el` init file. A better solution is to configure your favored editor to perform
formatting automatically. For instance `emacs` users should copy-past
the following code to their `.emacs.el` init file.
```lisp ```lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Clang-format ;; Clang-format
......
...@@ -18,12 +18,3 @@ add_dependencies(PugsLanguage ...@@ -18,12 +18,3 @@ add_dependencies(PugsLanguage
PugsLanguageModules PugsLanguageModules
PugsLanguageUtils PugsLanguageUtils
PugsUtils) PugsUtils)
# ------------------- Installation --------------------
# temporary version workaround
if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
install(TARGETS PugsLanguage
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
...@@ -30,15 +30,3 @@ add_library( ...@@ -30,15 +30,3 @@ add_library(
MeshRandomizer.cpp MeshRandomizer.cpp
MeshTransformer.cpp MeshTransformer.cpp
SynchronizerManager.cpp) SynchronizerManager.cpp)
# Additional dependencies
#add_dependencies(PugsMesh)
# ------------------- Installation --------------------
# temporary version workaround
if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
install(TARGETS PugsMesh
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
...@@ -6,12 +6,3 @@ add_library( ...@@ -6,12 +6,3 @@ add_library(
GnuplotWriter1D.cpp GnuplotWriter1D.cpp
VTKWriter.cpp VTKWriter.cpp
WriterBase.cpp) WriterBase.cpp)
# ------------------- Installation --------------------
# temporary version workaround
if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
install(TARGETS PugsMesh
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
...@@ -112,12 +112,3 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pugs_config.hpp.in" ...@@ -112,12 +112,3 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pugs_config.hpp.in"
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pugs_build_info.hpp.in" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pugs_build_info.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/pugs_build_info.hpp" "${CMAKE_CURRENT_BINARY_DIR}/pugs_build_info.hpp"
@ONLY) @ONLY)
# ------------------- Installation --------------------
# temporary version workaround
if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
install(TARGETS PugsUtils
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment