Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions FindCMDEF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_LINK_OPTION.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_INSTALL.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_PACKAGE.cmake)

INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_CLEANUP.cmake)

INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_HELPER.cmake)

6 changes: 3 additions & 3 deletions doc/CacheVariables.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ It tries to set the variable in the following order

## CMDEF_BUILD_TYPE_CMAKE_BUILD_TYPE_OVERRIDE:BOOL=\<conditional>

Indicate if the CMAKE_BUILD_TYPE is overriden by CMDEF library.
Indicate if the CMAKE_BUILD_TYPE is overridden by CMDEF library.

- If the CMAKE_BUILD_TYPE is not set the CMDEF try to set the CMAKE_BUILD_TYPE variable
to the predefined value stored in CMDEF_BUILD_TYPE_DEFAULT variable. In this case the vairable is set to ON.
to the predefined value stored in CMDEF_BUILD_TYPE_DEFAULT variable. In this case the variable is set to ON.
- If the CMAKE_BUILD_TYPE is set explicitly the variable is set to OFF.

## CMDEF_BUILD_TYPE_DEFAULT:STRING=Debug
Expand All @@ -43,7 +43,7 @@ Default build type if CMAKE_BUILD_TYPE is not specified.

## CMDEF_BUILD_TYPE_LIST:STRING,LIST=\<conditional>

List of the suported byuld types. CMAKE_BUILD_TYPE must hold exactly one value from this list.
List of the supported byuld types. CMAKE_BUILD_TYPE must hold exactly one value from this list.

Type: String, List

Expand Down
16 changes: 13 additions & 3 deletions example/executable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PROJECT(${CMAKE_PROJECT_NAME})
FIND_PACKAGE(CMLIB COMPONENTS CMDEF)


CMDEF_CLEANUP()

#
# Add Definitions for each build type globally
Expand All @@ -36,7 +37,7 @@ IF(CMDEF_OS_LINUX)
)
ELSEIF(CMDEF_OS_WINDOWS)
CMDEF_COMPILE_OPTIONS(
ALL /wd4996 # Disable deprectation warning on Windows OS
ALL /wd4996 # Disable deprecation warning on Windows OS
)
ENDIF()

Expand All @@ -53,7 +54,7 @@ CMDEF_ADD_EXECUTABLE(

CMDEF_COMPILE_DEFINITIONS_TARGET(
TARGET executable
VISIBLITY PUBLIC
VISIBILITY PUBLIC
ALL RETURN_CODE=245
DEBUG RETURN_CODE_DEBUG=1000
RELEASE RETURN_CODE_RELEASE=2020
Expand All @@ -66,7 +67,7 @@ CMDEF_COMPILE_DEFINITIONS_TARGET(
ADD_EXECUTABLE(cmake_executable main.c)
CMDEF_COMPILE_DEFINITIONS_TARGET(
TARGET cmake_executable
VISIBLITY PRIVATE
VISIBILITY PRIVATE
ALL RETURN_CODE=255
DEBUG RETURN_CODE_DEBUG=10000
RELEASE RETURN_CODE_RELEASE=20200
Expand Down Expand Up @@ -94,3 +95,12 @@ CMDEF_PACKAGE(
#
SET(CPACK_GENERATOR ZIP)
INCLUDE(CPack)

function(dump_cmake_variables)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName IN LISTS _variableNames)
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
endfunction()
dump_cmake_variables()
2 changes: 1 addition & 1 deletion example/library-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CMDEF_INSTALL(TARGET testlink-executable NAMESPACE testlib-shared::)
#
CMDEF_COMPILE_OPTIONS_TARGET(
TARGET testlib-shared
VISIBLITY PUBLIC
VISIBILITY PUBLIC
DEBUG -Wall
)

Expand Down
2 changes: 1 addition & 1 deletion example/library-interface/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @brief Test exacutable to test all defined symbols are linked correctly
* @brief Test executable to test all defined symbols are linked correctly
*/

#include <testlib/printAllMessages.hpp>
Expand Down
2 changes: 1 addition & 1 deletion example/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CMDEF_ADD_LIBRARY(
#
CMDEF_COMPILE_OPTIONS_TARGET(
TARGET testlib-shared
VISIBLITY PUBLIC
VISIBILITY PUBLIC
DEBUG -Wall
)

Expand Down
4 changes: 2 additions & 2 deletions system_modules/CMDEF_BUILD_TYPE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SET(CMDEF_BUILD_TYPE_DEFAULT "Debug"
MACRO(_CMDEF_BUILD_TYPE_SET_CMAKE_BUILD_TYPE_OVERRIDE opt ${ARGN})
SET(CMDEF_BUILD_TYPE_CMAKE_BUILD_TYPE_OVERRIDE ${opt}
CACHE BOOL
"ON if the CMAKE_BUILD_TYPE is overriden by CMDEF, OFF otherwise"
"ON if the CMAKE_BUILD_TYPE is overridden by CMDEF, OFF otherwise"
${ARGN}
)
ENDMACRO()
Expand Down Expand Up @@ -65,7 +65,7 @@ UNSET(all_find)


##
# Initialize CMake veriables according to CMDEF definitions
# Initialize CMake variables according to CMDEF definitions
#
# <function>(
# )
Expand Down
18 changes: 9 additions & 9 deletions system_modules/CMDEF_COMPILE_DEFINITION.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMDEF_ADD_LIBRARY.cmake)
# from BUILD_TYPE list.
#
# LANG -array, if specified must be one of CMDEF_SUPPORTED_LANG_LIST.
# If not specified no exact languege is select
# If not specified no exact language is select
#
# Each definition is passed to ADD_COMPILE_DEFINITION
# by generator_expression $<<CONFIG:build_type>:${definitnion}>
Expand Down Expand Up @@ -78,20 +78,20 @@ ENDFUNCTION()
# from BUILD_TYPE list.
#
# LANG - array, if specified must be one of CMDEF_SUPPORTED_LANG_LIST.
# If not specified no exact languege is select
# If not specified no exact language is select
#
# Each definition is passed to TARGET_COMPILE_DEFINITION
# by generator_expression $<<CONFIG:build_type>:${definitnion}>
#
# VISIBLITY is passed to visiblity section of TARGET_LINK_OPTIONS.
# If no visiblity specified than visiblity is omitted
# VISIBILITY is passed to visibility section of TARGET_LINK_OPTIONS.
# If no visibility specified than visibility is omitted
#
# <function>(
# TARGET <target>
# [LANG <lang> M]
# [ALL <compile_definitions>]
# [<BUILD_TYPE_UPPERCASE> <link_options>]{1,}
# [VISIBLITY <INTERFACE|PUBLIC|PRIVATE>]
# [VISIBILITY <INTERFACE|PUBLIC|PRIVATE>]
# )
#
FUNCTION(CMDEF_COMPILE_DEFINITIONS_TARGET)
Expand All @@ -101,9 +101,9 @@ FUNCTION(CMDEF_COMPILE_DEFINITIONS_TARGET)
${CMDEF_BUILD_TYPE_LIST_UPPERCASE}
ONE_VALUE
TARGET
VISIBLITY
VISIBILITY
REQUIRED
TARGET VISIBLITY
TARGET VISIBILITY
P_ARGN ${ARGN}
)

Expand All @@ -125,9 +125,9 @@ FUNCTION(CMDEF_COMPILE_DEFINITIONS_TARGET)
IF(DEFINED __LANG)
SET(condition $<AND:$<COMPILE_LANGUAGE:${__LANG}>,$<CONFIG:${build_type}>>)
SET(compile_definitions $<${condition}:${${build_type_var}}>)
TARGET_COMPILE_DEFINITIONS(${original_target_name} ${__VISIBLITY} ${compile_definitions})
TARGET_COMPILE_DEFINITIONS(${original_target_name} ${__VISIBILITY} ${compile_definitions})
ELSE()
TARGET_COMPILE_DEFINITIONS(${original_target_name} ${__VISIBLITY} $<$<CONFIG:${build_type}>:${${build_type_var}}>)
TARGET_COMPILE_DEFINITIONS(${original_target_name} ${__VISIBILITY} $<$<CONFIG:${build_type}>:${${build_type_var}}>)
ENDIF()
ENDFOREACH()
ENDFUNCTION()
18 changes: 9 additions & 9 deletions system_modules/CMDEF_COMPILE_OPTION.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMDEF_ADD_LIBRARY.cmake)
# from BUILD_TYPE list.
#
# LANG - array, If specified must be on CMDEF_SUPPORTED_LANG_LIST.
# If not specified no exact languege is select
# If not specified no exact language is select
#
# Each definition is passed to ADD_COMPILE_OPTIONS
# by generator_expression $<<CONFIG:build_type>:${option}>
Expand Down Expand Up @@ -79,20 +79,20 @@ ENDMACRO()
# to each BUILD_TYPE
#
# LANG - array, if specified must be one of CMDEF_SUPPORTED_LANG_LIST.
# If not specified no exact languege is select
# If not specified no exact language is select
#
# Each definition is passed to ADD_COMPILE_OPTIONS
# by generator_expression $<<CONFIG:build_type>:${option}>
#
# VISIBLITY is passed to visiblity section of TARGET_LINK_OPTIONS.
# If no visiblity specified than visiblity is omitted
# VISIBILITY is passed to visibility section of TARGET_LINK_OPTIONS.
# If no visibility specified than visibility is omitted
#
# <function> (
# TARGET <target>
# [LANG <lang_list>]
# [ALL <compile_options>]
# [<BUILD_TYPE_UPPERCASE> <link_options>]{1,}
# [VISIBLITY <INTERFACE|PUBLIC|PRIVATE>]
# [VISIBILITY <INTERFACE|PUBLIC|PRIVATE>]
# )
#
FUNCTION(CMDEF_COMPILE_OPTIONS_TARGET)
Expand All @@ -102,10 +102,10 @@ FUNCTION(CMDEF_COMPILE_OPTIONS_TARGET)
${CMDEF_BUILD_TYPE_LIST_UPPERCASE}
ONE_VALUE
TARGET
VISIBLITY
VISIBILITY
REQUIRED
TARGET
VISIBLITY
VISIBILITY
P_ARGN ${ARGN}
)

Expand All @@ -128,9 +128,9 @@ FUNCTION(CMDEF_COMPILE_OPTIONS_TARGET)
SET(option ${${build_type_var}})
SET(condition $<AND:$<COMPILE_LANGUAGE:${__LANG}>,$<CONFIG:${build_type}>>)
SET(compile_options $<${condition}:${option}>)
TARGET_COMPILE_OPTIONS(${original_target_name} ${__VISIBLITY} ${compile_options})
TARGET_COMPILE_OPTIONS(${original_target_name} ${__VISIBILITY} ${compile_options})
ELSE()
TARGET_COMPILE_OPTIONS(${original_target_name} ${__VISIBLITY} $<$<CONFIG:${build_type}>:${${build_type_var}}>)
TARGET_COMPILE_OPTIONS(${original_target_name} ${__VISIBILITY} $<$<CONFIG:${build_type}>:${${build_type_var}}>)
ENDIF()
ENDFOREACH()
ENDFUNCTION()
Expand Down
11 changes: 5 additions & 6 deletions system_modules/CMDEF_ENV.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# initialize base CMDEF CMake variables.
#
# Module relay on some CMake variables like
# - CMAKE_SIZEOF_VOID_P (not defined for Script mode)
# - CMAKE_CURRENT_BINARY_DIR (defined as "${CMAKE_CURRENT_LIST_DIR}" for script mode)
#

Expand Down Expand Up @@ -281,7 +280,7 @@ MACRO(_CMDEF_ENV_SET_OS)
ENDIF()
SET(CMDEF_ARCHITECTURE ${arch}
CACHE STRING
"Achitecture for which we will compile"
"Architecture for which we will compile"
)
ENDIF()
MESSAGE(STATUS "Architecture: ${CMDEF_ARCHITECTURE}")
Expand Down Expand Up @@ -377,7 +376,7 @@ ENDMACRO()
#
FUNCTION(_CMDEF_ENV_SET_WINDOWS_FLAGS)
IF(NOT DEFINED CMDEF_OS_WINDOWS)
MESSAGE(FATAL_ERROR "Canot determine target OS. Not defined.")
MESSAGE(FATAL_ERROR "Cannot determine target OS. Not defined.")
ENDIF()
IF(NOT CMDEF_OS_WINDOWS)
RETURN()
Expand All @@ -404,7 +403,7 @@ FUNCTION(_CMDEF_ENV_SET_DESCRIPTION)
)
SET(CMDEF_ENV_DESCRIPTION_COPYRIGHT "${CMDEF_ENV_DESCRIPTION_COMPANY_NAME}"
CACHE STRING
"Copyrigth which will be added to binaries"
"Copyright which will be added to binaries"
)
ENDFUNCTION()

Expand Down Expand Up @@ -469,7 +468,7 @@ FUNCTION(_CMDEF_ENV_GET_DISTRO_ID distro_id)
STRING(TOLOWER "${_distro_id_mapped}" _distro_id_normalized)
IF(NOT _distro_id_normalized)
MESSAGE(FATAL_ERROR "Cannot determine Distro ID."
"It seems the system has Distro ID set to empty or invalid string."
" It seems the system has Distro ID set to empty or invalid string."
" Consult os-release file."
)
ENDIF()
Expand Down Expand Up @@ -503,7 +502,7 @@ FUNCTION(_CMDEF_ENV_GET_DISTRO_VERSION_ID version_id)
STRING(REGEX REPLACE "[^a-zA-Z0-9.]" "-" _version_id_mapped "${_version_id}")
STRING(TOLOWER "${_version_id_mapped}" _version_id_normalized)
IF(NOT _version_id_normalized)
MESSAGE(FATAL "Cannot determine Distro Version ID."
MESSAGE(FATAL_ERROR "Cannot determine Distro Version ID."
" It seems the system has Distro Version ID set to empty or invalid string."
" Consult os-release file."
)
Expand Down
16 changes: 8 additions & 8 deletions system_modules/CMDEF_LINK_OPTION.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMDEF_ADD_LIBRARY.cmake)
# to each BUILD_TYPE
#
# LANG - array, if specified must be one of CMDEF_SUPPORTED_LANG_LIST.
# If not specified no exact languege is select
# If not specified no exact language is select
#
# Each definition is passed to ADD_LINK_OPTIONS
# by generator_expression $<<CONFIG:build_type>:${option}>
Expand Down Expand Up @@ -78,20 +78,20 @@ ENDFUNCTION()
# to each BUILD_TYPE
#
# LANG - array, if specified must be one of CMDEF_SUPPORTED_LANG_LIST.
# If not specified no exact languege is select
# If not specified no exact language is select
#
# Each definition is passed to ADD_LINK_OPTIONS
# by generator_expression $<<CONFIG:build_type>:${option}>
#
# VISIBLITY is passed to visiblity section of TARGET_LINK_OPTIONS.
# If no visiblity specified than visiblity is omitted
# VISIBILITY is passed to visibility section of TARGET_LINK_OPTIONS.
# If no visibility specified than visibility is omitted
#
# <function>(
# TARGET <target>
# [LANG <lang> M]
# [ALL <compile_options>]
# [<BUILD_TYPE_UPPERCASE> <link_options>]{1,}
# [VISIBLITY <INTERFACE|PUBLIC|PRIVATE>]
# [VISIBILITY <INTERFACE|PUBLIC|PRIVATE>]
# )
#
FUNCTION(CMDEF_LINK_OPTIONS_TARGET)
Expand All @@ -101,7 +101,7 @@ FUNCTION(CMDEF_LINK_OPTIONS_TARGET)
${CMDEF_BUILD_TYPE_LIST_UPPERCASE}
ONE_VALUE
TARGET
VISIBLITY
VISIBILITY
REQUIRED
TARGET
P_ARGN ${ARGN}
Expand All @@ -126,9 +126,9 @@ FUNCTION(CMDEF_LINK_OPTIONS_TARGET)
SET(option ${${build_type_var}})
SET(condition $<AND:$<COMPILE_LANGUAGE:${__LANG}>,$<CONFIG:${build_type}>>)
SET(link_options $<${condition}:${option}>)
TARGET_LINK_OPTIONS(${original_target_name} ${__VISIBLITY} ${link_options})
TARGET_LINK_OPTIONS(${original_target_name} ${__VISIBILITY} ${link_options})
ELSE()
TARGET_LINK_OPTIONS(${original_target_name} ${__VISIBLITY} $<$<CONFIG:${build_type}>:${${build_type_var}}>)
TARGET_LINK_OPTIONS(${original_target_name} ${__VISIBILITY} $<$<CONFIG:${build_type}>:${${build_type_var}}>)
ENDIF()
ENDFOREACH()
ENDFUNCTION()
4 changes: 2 additions & 2 deletions system_modules/CMDEF_RESOURCE.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Main
#
# Manage resources for binaries. Specialy for Windows.
# Manage resources for binaries. Specially for Windows.
#

INCLUDE_GUARD(GLOBAL)
Expand All @@ -17,7 +17,7 @@ FIND_PACKAGE(CMLIB REQUIRED)
# RESOURCE_FILE is absolute path to Resource file
#
# DEFINITIONS is list of key-value pairs which is treated as
# definitons for cmd line command which process RESOURCE_FILE
# definitions for cmd line command which process RESOURCE_FILE
#
# <function> (
# RESOURCE_TARGET <resource_target>
Expand Down