Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further CMake build scripts cleanup.
Finds optional documentation packages only if documentation target is registered. Removes circular dependency between root CMakeLists file and CMake package configuration file. Adds support for selecting MSVC runtime library linkage mode (facilitates embedding in projects that might require a specific linkage mode for 3rd-party libraries).
- Loading branch information
1 parent
fec5f48
commit 04626cf
Showing
5 changed files
with
149 additions
and
62 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Compile API documentation from source code. | ||
function(add_api_documentation target) | ||
if(DOXYGEN_EXECUTABLE) | ||
add_custom_target( | ||
${target} | ||
COMMAND | ||
${DOXYGEN_EXECUTABLE} | ||
WORKING_DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
COMMENT | ||
"Compiling documentation." | ||
VERBATIM | ||
) | ||
endif() | ||
endfunction() |
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,88 @@ | ||
# Copyright (c) 2009-2012, Andre Caron (andre.l.caron@gmail.com) | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are | ||
# met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# List CMake variables containing build flags. | ||
set(CMAKE_COMPILER_FLAGS_VARIABLES | ||
CMAKE_C_FLAGS_DEBUG | ||
CMAKE_C_FLAGS_MINSIZEREL | ||
CMAKE_C_FLAGS_RELEASE | ||
CMAKE_C_FLAGS_RELWITHDEBINFO | ||
CMAKE_CXX_FLAGS_DEBUG | ||
CMAKE_CXX_FLAGS_MINSIZEREL | ||
CMAKE_CXX_FLAGS_RELEASE | ||
CMAKE_CXX_FLAGS_RELWITHDEBINFO | ||
) | ||
|
||
# Select static or dynamic MSVC runtime based on 'MSVC_RUNTIME' variable. | ||
# This variable can be set through the command-line like so: | ||
# | ||
# cmake -G "..." -DMSVC_RUNTIME=static | ||
# | ||
# Acceptable values are "static" (default) and "dynamic". | ||
macro(msvc_configure_runtime) | ||
if(MSVC) | ||
# Default to statically-linked runtime. | ||
if("${MSVC_RUNTIME}" STREQUAL "") | ||
set(MSVC_RUNTIME "static") | ||
endif() | ||
# Set compiler options. | ||
if(${MSVC_RUNTIME} STREQUAL "static") | ||
message(STATUS | ||
"MSVC -> forcing use of statically-linked runtime." | ||
) | ||
foreach(variable ${CMAKE_COMPILER_FLAGS_VARIABLES}) | ||
if(${variable} MATCHES "/MD") | ||
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") | ||
endif() | ||
endforeach() | ||
else() | ||
message(STATUS | ||
"MSVC -> forcing use of dynamically-linked runtime." | ||
) | ||
foreach(variable ${CMAKE_COMPILER_FLAGS_VARIABLES}) | ||
if(${variable} MATCHES "/MT") | ||
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}") | ||
endif() | ||
endforeach() | ||
endif() | ||
endif() | ||
endmacro() | ||
|
||
# Enable Microsoft's structured exception handling. | ||
macro(msvc_enable_se_handling) | ||
if(MSVC) | ||
message(STATUS | ||
"MSVC -> enabling structured exception hanlding." | ||
) | ||
if(CMAKE_CXX_FLAGS MATCHES "/EH") | ||
string(REGEX REPLACE | ||
"/EH[acs]+" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" | ||
) | ||
else() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa") | ||
endif() | ||
endif() | ||
endmacro() |
File renamed without changes.
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,20 @@ | ||
# Render PlantUML diagrams to PNG. | ||
function(add_diagram target source) | ||
if(Java_JAVA_EXECUTABLE AND PLANTUML_JARFILE) | ||
set(plantuml ${Java_JAVA_EXECUTABLE} -jar ${PLANTUML_JARFILE}) | ||
get_filename_component(output ${source} NAME_WE) | ||
add_custom_command( | ||
OUTPUT | ||
${CMAKE_CURRENT_BINARY_DIR}/${output}.png | ||
COMMAND | ||
${plantuml} -o ${CMAKE_CURRENT_BINARY_DIR} -tpng ${source} | ||
MAIN_DEPENDENCY | ||
${source} | ||
COMMENT | ||
"Rendering UML diagram '${output}'." | ||
) | ||
add_custom_target(${target} | ||
ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output}.png | ||
) | ||
endif() | ||
endfunction() |