Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to call project() in the root CMakeLists.txt (#242)
* Make it possible to call project() in the root CMakeLists.txt This deprecates the use of setup_project() in favor of: ``` set(PROJECT_NAME "MyProject") set(PROJECT_DESCRIPTION "...") set(PROJECT_URL "...") include(cmake/base.cmake) project(${PROJECT_NAME} CXX) ``` which is going to be CMake friendly from 3.15 onwards To do so, including cmake/base.cmake will have the following effect: - setup a script to call after project() is called - compute PROJECT_VERSION and restore its value after project() is called (we cannot use the VERSION argument of project() because we compute incompatible version numbers) - setup a hook to call setup_project_finalize() and optionally setup_project_package_finalize() * [base] Add a link to minimal example if variables are not defined
- Loading branch information
Showing
6 changed files
with
149 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) | ||
|
||
INCLUDE(cmake/base.cmake) | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
# These variables have to be defined before running SETUP_PROJECT | ||
SET(PROJECT_NAME jrl-cmakemodules-minimal-working-example) | ||
SET(PROJECT_DESCRIPTION "A project description") | ||
SET(PROJECT_URL http://jrl-cmakemodules.readthedocs.io) | ||
set(PROJECT_NAME jrl-cmakemodules-minimal-working-example) | ||
set(PROJECT_DESCRIPTION "A project description") | ||
set(PROJECT_URL http://jrl-cmakemodules.readthedocs.io) | ||
|
||
SETUP_PROJECT() | ||
include(cmake/base.cmake) | ||
|
||
# Configure the build of your project here | ||
# ADD_SUBDIRECTORY(src) | ||
project(${PROJECT_NAME} CXX) | ||
|
||
# This should be called at the end | ||
SETUP_PROJECT_FINALIZE() | ||
# Configure the build of your project here | ||
# add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Restore version information that might have been overriden by project() call | ||
SET(PROJECT_VERSION "${SAVED_PROJECT_VERSION}") | ||
SET(PROJECT_VERSION_MAJOR "${SAVED_PROJECT_VERSION_MAJOR}") | ||
SET(PROJECT_VERSION_MINOR "${SAVED_PROJECT_VERSION_MINOR}") | ||
SET(PROJECT_VERSION_PATCH "${SAVED_PROJECT_VERSION_PATCH}") | ||
|
||
IF(DEFINED PROJECT_DEBUG_POSTFIX) | ||
SET(CMAKE_DEBUG_POSTFIX ${PROJECT_DEBUG_POSTFIX}) | ||
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type) | ||
IF(${cmake_build_type} MATCHES debug) | ||
SET(PKGCONFIG_POSTFIX ${PROJECT_DEBUG_POSTFIX}) | ||
ELSE() | ||
SET(PKGCONFIG_POSTFIX "") | ||
ENDIF() | ||
IF(DEFINED CMAKE_CONFIGURATION_TYPES) | ||
SET(PKGCONFIG_POSTFIX ${PROJECT_DEBUG_POSTFIX}) | ||
ENDIF() | ||
ENDIF() | ||
|
||
IF(NOT DEFINED PROJECT_USE_KEYWORD_LINK_LIBRARIES) | ||
SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES FALSE) | ||
ENDIF() | ||
IF(${PROJECT_USE_KEYWORD_LINK_LIBRARIES}) | ||
SET(PUBLIC_KEYWORD PUBLIC) | ||
ELSE() | ||
SET(PUBLIC_KEYWORD "") | ||
ENDIF() | ||
|
||
IF(${ARGC}) | ||
SET(CMAKE_VERBOSE_MAKEFILE ${ARGV0}) | ||
ELSE(${ARGC}) | ||
# Be verbose by default. | ||
SET(CMAKE_VERBOSE_MAKEFILE TRUE) | ||
ENDIF(${ARGC}) | ||
|
||
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" ON) | ||
OPTION(INSTALL_GENERATED_HEADERS "Generate and install standard headers" ON) | ||
OPTION(INSTALL_PKG_CONFIG_FILE "Generate and install standard .pc file" ON) | ||
|
||
INCLUDE(CTest) | ||
ENABLE_TESTING() | ||
|
||
LOGGING_INITIALIZE() | ||
|
||
#FIXME: normalize naming to <MODULE>_SETUP() | ||
_SETUP_PROJECT_WARNINGS() | ||
_SETUP_PROJECT_HEADER() | ||
_SETUP_PROJECT_DIST() | ||
DISTCHECK_SETUP() | ||
RELEASE_SETUP() | ||
_SETUP_PROJECT_DEB() | ||
_SETUP_PROJECT_UNINSTALL() | ||
_SETUP_PROJECT_PKG_CONFIG() | ||
_SETUP_PROJECT_DOCUMENTATION() | ||
_SETUP_PROJECT_PACKAGE_INIT() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters