Improve coding style in CMake modules

This commit is contained in:
Martchus 2018-02-21 23:00:32 +01:00
parent eea5aa57bc
commit 0dcbb3de55
5 changed files with 443 additions and 437 deletions

View File

@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
if(NOT DEFINED THIRD_PARTY_MODULE_LOADED)
# prevent multiple inclusion
if(DEFINED THIRD_PARTY_MODULE_LOADED)
return()
endif()
set(THIRD_PARTY_MODULE_LOADED YES)
macro(save_default_library_suffixes)
set(DEFAULT_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
@ -267,6 +271,3 @@ if(NOT DEFINED THIRD_PARTY_MODULE_LOADED)
use_external_library(iconv ${LINKAGE} ${REQUIRED})
endif()
endmacro()
set(THIRD_PARTY_MODULE_LOADED YES)
endif()

View File

@ -3,8 +3,10 @@ if(NOT BASIC_PROJECT_CONFIG_DONE)
endif()
option(NO_DOXYGEN "whether creation of Doxygen targets is disabled (enabled by default)" OFF)
if(NOT NO_DOXYGEN)
return()
endif()
# find doxygen.h template
include(TemplateFinder)
find_template_file("doxygen" CPP_UTILITIES DOXYGEN_TEMPLATE_FILE)
@ -27,7 +29,9 @@ if(NOT NO_DOXYGEN)
if(NOT DOXYGEN_BIN)
message(WARNING "Doxygen not found, unable to add target for generating API documentation for ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
else()
return()
endif()
# load cached configuration and other variables
set(DOXY_LANGUAGE "English" CACHE STRING "specifies the language of the API documentation generated with Doxygen")
set(DOXY_CUSTOM_CONFIG "" CACHE STRING "specifies extra options for Doxygen")
@ -75,6 +79,3 @@ if(NOT NO_DOXYGEN)
endif()
message(STATUS "Generating target for generating API documentation for ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} with Doxygen")
endif()
endif()

View File

@ -4,8 +4,10 @@ endif()
option(SHELL_COMPLETION_ENABLED "controls whether shell completion is enabled in general" ON)
option(BASH_COMPLETION_ENABLED "controls whether shell completion for bash is enabled" ON)
if(NOT SHELL_COMPLETION_ENABLED)
return()
endif()
if(SHELL_COMPLETION_ENABLED)
# add bash completion (currently the only supported shell completion)
if(BASH_COMPLETION_ENABLED)
# find bash-completion.sh template
@ -34,4 +36,3 @@ if(SHELL_COMPLETION_ENABLED)
message(STATUS "Generating files for bash completion.")
endif()
endif()

View File

@ -1,4 +1,8 @@
if(NOT DEFINED TEMPLATE_FINDER_LOADED)
# prevent multiple inclusion
if(DEFINED TEMPLATE_FINDER_LOADED)
return()
endif()
set(TEMPLATE_FINDER_LOADED YES)
function(find_template_file FILE_NAME PROJECT_VAR_NAME OUTPUT_VAR)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/${FILE_NAME}.in")
@ -17,6 +21,3 @@ if(NOT DEFINED TEMPLATE_FINDER_LOADED)
message(FATAL_ERROR "Template for ${FILE_NAME} file can not be located.")
endif()
endfunction()
set(TEMPLATE_FINDER_LOADED YES)
endif()

View File

@ -6,10 +6,13 @@ if(NOT BASIC_PROJECT_CONFIG_DONE)
message(FATAL_ERROR "Before including the WindowsResources module, the LibraryConfig/ApplicationConfig module must be included.")
endif()
option(WINDOWS_RESOURCES_ENABLED "controls Windows resources are enabled" ON)
option(WINDOWS_ICON_ENABLED "controls Windows icon is enabled" ON)
option(WINDOWS_RESOURCES_ENABLED "controls whether Windows resources are enabled" ON)
option(WINDOWS_ICON_ENABLED "controls whether Windows icon is enabled" ON)
if(NOT MINGW OR NOT WINDOWS_RESOURCES_ENABLED)
return()
endif()
if(MINGW AND WINDOWS_RESOURCES_ENABLED)
# find rc template
include(TemplateFinder)
find_template_file("windows.rc" CPP_UTILITIES RC_TEMPLATE_FILE)
@ -42,7 +45,7 @@ if(MINGW AND WINDOWS_RESOURCES_ENABLED)
message(FATAL_ERROR "The specified PNG_ICON_PATH \"${PNG_ICON_PATH}\" is invalid.")
endif()
unset(USING_DEFAULT_PNG_ICON_PATH)
endif(FFMPEG_BIN)
endif()
endif()
# create Windows rc file from template
@ -55,4 +58,3 @@ if(MINGW AND WINDOWS_RESOURCES_ENABLED)
set(CMAKE_RC_COMPILER_INIT windres)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
enable_language(RC)
endif()