Use option for CMake options
This commit is contained in:
parent
3301f8518f
commit
18845b3ce0
|
@ -46,8 +46,8 @@ configure_file(
|
|||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# disable new ABI (can't catch ios_base::failure with new ABI)
|
||||
set(FORCE_OLD_ABI "no" CACHE STRING "specifies whether usage of old ABI should be forced")
|
||||
if(${FORCE_OLD_ABI} STREQUAL "yes")
|
||||
option(FORCE_OLD_ABI "specifies whether usage of old ABI should be forced" OFF)
|
||||
if(FORCE_OLD_ABI)
|
||||
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
|
||||
message(STATUS "Forcing usage of old CXX11 ABI.")
|
||||
endif()
|
||||
|
@ -59,7 +59,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||
endif()
|
||||
|
||||
# enable logging when option is set
|
||||
set(LOGGING_ENABLED "no" CACHE STRING "specifies whether logging is enabled")
|
||||
if(${LOGGING_ENABLED} STREQUAL "yes")
|
||||
option(LOGGING_ENABLED "specifies whether logging is enabled" OFF)
|
||||
if(LOGGING_ENABLED)
|
||||
add_definitions(-DLOGGING_ENABLED)
|
||||
message(STATUS "Logging is enabled.")
|
||||
endif()
|
||||
|
|
|
@ -55,21 +55,24 @@ if(MINGW)
|
|||
endif(MINGW)
|
||||
|
||||
# add target for building the library
|
||||
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} SHARED ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_FILES} ${QML_FILES} ${RES_FILES} ${QM_FILES} ${WINDOWS_ICON_PATH})
|
||||
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${LIBRARIES})
|
||||
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPERTIES
|
||||
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
|
||||
SOVERSION ${META_VERSION_MAJOR}
|
||||
CXX_STANDARD 11
|
||||
)
|
||||
option(BUILD_SHARED_LIBS "whether to build dynamic libraries (enabled by default)" ON)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} SHARED ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_FILES} ${QML_FILES} ${RES_FILES} ${QM_FILES} ${WINDOWS_ICON_PATH})
|
||||
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${LIBRARIES})
|
||||
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPERTIES
|
||||
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
|
||||
SOVERSION ${META_VERSION_MAJOR}
|
||||
CXX_STANDARD 11
|
||||
)
|
||||
endif()
|
||||
|
||||
# add target for building a static version of the library
|
||||
if(MINGW)
|
||||
set(BUILD_STATIC_LIBS "yes" CACHE STRING "specifies whether to build static libraries (enabled by default on mingw-w64 platform)")
|
||||
option(BUILD_STATIC_LIBS "whether to build static libraries (enabled by default on mingw-w64 platform)" ON)
|
||||
else()
|
||||
set(BUILD_STATIC_LIBS "no" CACHE STRING "specifies whether to build static libraries (disabled by default on none-mingw-w64- platform)")
|
||||
option(BUILD_STATIC_LIBS "whether to build static libraries (disabled by default on none-mingw-w64- platform)" OFF)
|
||||
endif()
|
||||
if(${BUILD_STATIC_LIBS} STREQUAL "yes")
|
||||
if(BUILD_STATIC_LIBS)
|
||||
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static STATIC ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_FILES} ${QML_FILES} ${RES_FILES} ${QM_FILES} ${WINDOWS_ICON_PATH})
|
||||
# add target link libraries for the static lib also because otherwise Qt header files can not be located
|
||||
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static ${LIBRARIES})
|
||||
|
@ -79,10 +82,7 @@ if(${BUILD_STATIC_LIBS} STREQUAL "yes")
|
|||
OUTPUT_NAME ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
|
||||
CXX_STANDARD 11
|
||||
)
|
||||
elseif(${BUILD_STATIC_LIBS} STREQUAL "no")
|
||||
else()
|
||||
message(FATAL_ERROR "The specification whether to build static libs or not is invalid.")
|
||||
endif(${BUILD_STATIC_LIBS} STREQUAL "yes")
|
||||
endif()
|
||||
|
||||
# add install target for the CMake config files
|
||||
install(
|
||||
|
@ -103,15 +103,17 @@ if(NOT TARGET install-cmake-config)
|
|||
endif()
|
||||
|
||||
# add install target for dynamic libs
|
||||
install(
|
||||
TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
|
||||
RUNTIME DESTINATION bin
|
||||
COMPONENT binary
|
||||
LIBRARY DESTINATION lib${SELECTED_LIB_SUFFIX}
|
||||
COMPONENT binary
|
||||
ARCHIVE DESTINATION lib${SELECTED_LIB_SUFFIX}
|
||||
COMPONENT binary
|
||||
)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(
|
||||
TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
|
||||
RUNTIME DESTINATION bin
|
||||
COMPONENT binary
|
||||
LIBRARY DESTINATION lib${SELECTED_LIB_SUFFIX}
|
||||
COMPONENT binary
|
||||
ARCHIVE DESTINATION lib${SELECTED_LIB_SUFFIX}
|
||||
COMPONENT binary
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET install-binary)
|
||||
add_custom_target(install-binary
|
||||
|
@ -121,7 +123,7 @@ if(NOT TARGET install-binary)
|
|||
endif()
|
||||
|
||||
# add install for static libs when building with mingw-w64
|
||||
if(${BUILD_STATIC_LIBS} STREQUAL "yes")
|
||||
if(BUILD_STATIC_LIBS)
|
||||
install(
|
||||
TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static
|
||||
RUNTIME DESTINATION bin
|
||||
|
@ -131,7 +133,7 @@ if(${BUILD_STATIC_LIBS} STREQUAL "yes")
|
|||
ARCHIVE DESTINATION lib${SELECTED_LIB_SUFFIX}
|
||||
COMPONENT binary
|
||||
)
|
||||
endif(${BUILD_STATIC_LIBS} STREQUAL "yes")
|
||||
endif()
|
||||
|
||||
# add install target for stripped libs
|
||||
if(NOT TARGET install-binary-strip)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
set(SHELL_COMPLETION_ENABLED "yes" CACHE STRING "controls whether shell completion is enabled")
|
||||
set(BASH_COMPLETION_ENABLED "yes" CACHE STRING "controls whether bash completion is enabled")
|
||||
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(${SHELL_COMPLETION_ENABLED} STREQUAL "yes")
|
||||
if(SHELL_COMPLETION_ENABLED)
|
||||
|
||||
if(NOT COMPLETION_META_PROJECT_NAME)
|
||||
set(COMPLETION_META_PROJECT_NAME ${META_PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
# add bash completion (currently the only supported shell completion)
|
||||
if(${BASH_COMPLETION_ENABLED} STREQUAL "yes")
|
||||
if(BASH_COMPLETION_ENABLED)
|
||||
# find bash-completion.sh template
|
||||
include(TemplateFinder)
|
||||
find_template_file("bash-completion.sh" CPP_UTILITIES BASH_COMPLETION_TEMPLATE_FILE)
|
||||
|
@ -30,6 +30,8 @@ if(${SHELL_COMPLETION_ENABLED} STREQUAL "yes")
|
|||
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=bash-completion -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||
)
|
||||
endif()
|
||||
|
||||
message(STATUS "Generating files for bash completion.")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue