2016-04-16 00:50:16 +02:00
|
|
|
# before including this module, the project meta-data must be set
|
|
|
|
|
|
|
|
# set project name (displayed in Qt Creator)
|
|
|
|
project(${META_PROJECT_NAME})
|
|
|
|
|
2016-04-16 18:32:22 +02:00
|
|
|
# provide variables for other projects built as part of the same subdirs project
|
|
|
|
# to access files from this project
|
|
|
|
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
|
|
|
|
if(HAS_PARENT)
|
|
|
|
set(${META_PROJECT_VARNAME}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)
|
|
|
|
set(${META_PROJECT_VARNAME}_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
|
|
|
|
set(${META_PROJECT_NAME}_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
|
2016-07-16 23:04:22 +02:00
|
|
|
if(CMAKE_FIND_ROOT_PATH AND MINGW)
|
|
|
|
set(RUNTIME_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}" ${RUNTIME_LIBRARY_PATH} PARENT_SCOPE)
|
|
|
|
endif()
|
2016-04-16 18:32:22 +02:00
|
|
|
endif()
|
2016-04-16 00:50:16 +02:00
|
|
|
|
|
|
|
# stringify the meta data
|
|
|
|
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
|
|
|
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
|
|
|
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
|
|
|
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
|
|
|
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
|
|
|
set(META_APP_DESCRIPTION_STR "\"${META_APP_DESCRIPTION}\"")
|
|
|
|
set(META_APP_VERSION_STR "\"${META_APP_VERSION}\"")
|
|
|
|
|
2016-04-21 23:57:45 +02:00
|
|
|
# set META_PROJECT_VARNAME and META_PROJECT_VARNAME_UPPER if not specified explicitely
|
|
|
|
if(NOT META_PROJECT_VARNAME)
|
|
|
|
set(META_PROJECT_VARNAME ${META_PROJECT_NAME})
|
|
|
|
endif()
|
|
|
|
if(NOT META_PROJECT_VARNAME_UPPER)
|
|
|
|
string(TOUPPER ${META_PROJECT_VARNAME} META_PROJECT_VARNAME_UPPER)
|
|
|
|
endif()
|
|
|
|
|
2016-07-02 02:04:32 +02:00
|
|
|
# set TARGET_EXECUTABLE which is used to refer to the target executable at its installation location
|
|
|
|
set(TARGET_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bin/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
|
|
|
|
|
2016-04-16 00:50:16 +02:00
|
|
|
# disable new ABI (can't catch ios_base::failure with new ABI)
|
2016-07-10 00:16:24 +02:00
|
|
|
option(FORCE_OLD_ABI "specifies whether usage of old ABI should be forced" OFF)
|
|
|
|
if(FORCE_OLD_ABI)
|
2016-06-14 22:53:19 +02:00
|
|
|
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
|
2016-08-29 15:35:48 +02:00
|
|
|
set(META_REQUIRED_BUILD_FLAGS "${META_REQUIRED_BUILD_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
|
2016-06-14 22:53:19 +02:00
|
|
|
message(STATUS "Forcing usage of old CXX11 ABI.")
|
2016-07-16 23:04:22 +02:00
|
|
|
else()
|
|
|
|
message(STATUS "Using default CXX11 ABI (not forcing old CX11 ABI).")
|
2016-06-14 22:53:19 +02:00
|
|
|
endif()
|
2016-04-16 00:50:16 +02:00
|
|
|
|
|
|
|
# enable debug-only code when doing a debug build
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
add_definitions(-DDEBUG_BUILD)
|
|
|
|
message(STATUS "Debug build enabled.")
|
|
|
|
endif()
|
2016-07-03 22:13:04 +02:00
|
|
|
|
|
|
|
# enable logging when option is set
|
2016-07-10 00:16:24 +02:00
|
|
|
option(LOGGING_ENABLED "specifies whether logging is enabled" OFF)
|
|
|
|
if(LOGGING_ENABLED)
|
2016-07-03 22:13:04 +02:00
|
|
|
add_definitions(-DLOGGING_ENABLED)
|
2016-07-10 00:16:24 +02:00
|
|
|
message(STATUS "Logging is enabled.")
|
2016-07-03 22:13:04 +02:00
|
|
|
endif()
|
2016-07-22 01:35:32 +02:00
|
|
|
|
2016-08-19 16:13:41 +02:00
|
|
|
# options for deciding whether to build static and/or shared libraries
|
2016-08-29 15:35:48 +02:00
|
|
|
if(("${META_PROJECT_TYPE}" STREQUAL "library") OR ("${META_PROJECT_TYPE}" STREQUAL ""))
|
2016-09-06 22:51:00 +02:00
|
|
|
option(ENABLE_STATIC_LIBS "whether to building static libraries is enabled (disabled by default)" OFF)
|
|
|
|
option(DISABLE_SHARED_LIBS "whether building dynamic libraries is disabled (enabled by default)" OFF)
|
2016-08-29 15:35:48 +02:00
|
|
|
if(DISABLE_SHARED_LIBS)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
else()
|
2016-09-06 22:51:00 +02:00
|
|
|
set(BUILD_SHARED_LIBS ON)
|
|
|
|
endif()
|
|
|
|
if(ENABLE_STATIC_LIBS)
|
|
|
|
set(BUILD_STATIC_LIBS ON)
|
|
|
|
else()
|
|
|
|
set(BUILD_STATIC_LIBS OFF)
|
2016-08-29 15:35:48 +02:00
|
|
|
endif()
|
2016-08-19 16:13:41 +02:00
|
|
|
endif()
|
|
|
|
|
2016-07-22 01:35:32 +02:00
|
|
|
# options for forcing static linkage when building applications or dynamic libraries
|
2016-08-19 16:13:41 +02:00
|
|
|
if(("${META_PROJECT_TYPE}" STREQUAL "library") OR ("${META_PROJECT_TYPE}" STREQUAL ""))
|
|
|
|
option(STATIC_LIBRARY_LINKAGE "forces static linkage when building dynamic libraries" OFF)
|
|
|
|
elseif("${META_PROJECT_TYPE}" STREQUAL "application")
|
|
|
|
option(STATIC_LINKAGE "forces static linkage when building applications" OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# additional linker flags used when static linkage is enables
|
|
|
|
set(ADDITIONAL_STATIC_LINK_FLAGS -static -static-libstdc++ -static-libgcc)
|
2016-08-14 16:49:40 +02:00
|
|
|
|
|
|
|
# options for enabling/disabling Qt GUI (if available)
|
|
|
|
if(WIDGETS_HEADER_FILES OR WIDGETS_SRC_FILES OR WIDGETS_UI_FILES)
|
|
|
|
if(META_GUI_OPTIONAL)
|
|
|
|
option(WIDGETS_GUI "enables/disables building the Qt Widgets GUI: yes (default) or no" ON)
|
|
|
|
else()
|
|
|
|
set(WIDGETS_GUI ON)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(WIDGETS_GUI OFF)
|
|
|
|
endif()
|
|
|
|
if(QML_HEADER_FILES OR QML_SRC_FILES)
|
|
|
|
if(META_GUI_OPTIONAL)
|
|
|
|
option(QUICK_GUI "enables/disables building the Qt Quick GUI: yes (default) or no" ON)
|
|
|
|
else()
|
|
|
|
set(QUICK_GUI ON)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(QUICK_GUI OFF)
|
|
|
|
endif()
|