cpp-utilities/CMakeLists.txt

212 lines
6.4 KiB
CMake
Raw Normal View History

2015-12-05 22:47:49 +01:00
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
2015-12-08 08:32:57 +01:00
# add project files
set(HEADER_FILES
application/argumentparser.h
application/commandlineutils.h
application/failure.h
application/fakeqtconfigarguments.h
application/global.h
chrono/datetime.h
chrono/period.h
chrono/timespan.h
chrono/format.h
2015-12-08 08:32:57 +01:00
conversion/binaryconversion.h
conversion/binaryconversionprivate.h
conversion/conversionexception.h
conversion/stringconversion.h
conversion/stringbuilder.h
2015-12-08 08:32:57 +01:00
conversion/types.h
conversion/widen.h
io/ansiescapecodes.h
io/binaryreader.h
io/binarywriter.h
io/bitreader.h
io/copy.h
io/inifile.h
io/path.h
2016-06-14 22:53:19 +02:00
io/catchiofailure.h
io/nativefilestream.h
io/misc.h
2015-12-08 08:32:57 +01:00
math/math.h
misc/memory.h
misc/multiarray.h
2015-12-08 08:32:57 +01:00
misc/random.h
2016-11-13 22:51:09 +01:00
misc/traits.h
misc/levenshtein.h
tests/testutils.h
tests/cppunit.h
tests/outputcheck.h
2015-12-08 08:32:57 +01:00
)
set(SRC_FILES
2018-04-28 12:15:34 +02:00
application/argumentparserprivate.h
2015-12-08 08:32:57 +01:00
application/argumentparser.cpp
application/commandlineutils.cpp
application/failure.cpp
application/fakeqtconfigarguments.cpp
chrono/datetime.cpp
chrono/period.cpp
chrono/timespan.cpp
conversion/conversionexception.cpp
conversion/stringconversion.cpp
io/ansiescapecodes.cpp
io/binaryreader.cpp
io/binarywriter.cpp
io/bitreader.cpp
io/inifile.cpp
io/path.cpp
2016-06-14 22:53:19 +02:00
io/catchiofailure.cpp
io/nativefilestream.cpp
io/misc.cpp
2015-12-08 08:32:57 +01:00
math/math.cpp
misc/random.cpp
misc/levenshtein.cpp
tests/testutils.cpp
2015-12-08 08:32:57 +01:00
)
2016-01-25 23:59:52 +01:00
set(TEST_HEADER_FILES
)
set(TEST_SRC_FILES
tests/cppunit.cpp
tests/conversiontests.cpp
tests/iotests.cpp
2016-01-27 01:01:43 +01:00
tests/chronotests.cpp
2016-06-12 01:56:57 +02:00
tests/argumentparsertests.cpp
2017-05-08 19:59:29 +02:00
tests/traitstests.cpp
2017-08-02 13:29:22 +02:00
tests/mathtests.cpp
tests/misctests.cpp
2016-01-25 23:59:52 +01:00
)
2015-12-08 08:32:57 +01:00
set(CMAKE_MODULE_FILES
cmake/modules/BasicConfig.cmake
2016-08-03 17:33:26 +02:00
cmake/modules/ConfigHeader.cmake
cmake/modules/LibraryTarget.cmake
cmake/modules/TestTarget.cmake
cmake/modules/AppTarget.cmake
cmake/modules/WindowsResources.cmake
2016-06-09 22:57:51 +02:00
cmake/modules/TemplateFinder.cmake
cmake/modules/Doxygen.cmake
cmake/modules/ListToString.cmake
2016-07-03 22:36:48 +02:00
cmake/modules/ShellCompletion.cmake
cmake/modules/3rdParty.cmake
)
set(CMAKE_TEMPLATE_FILES
2016-09-11 21:02:20 +02:00
cmake/templates/bash-completion.sh.in
cmake/templates/Config.cmake.in
2018-02-16 23:56:29 +01:00
cmake/templates/SharedConfig.cmake.in
cmake/templates/StaticConfig.cmake.in
cmake/templates/config.h.in
cmake/templates/desktop.in
2018-02-19 19:50:07 +01:00
cmake/templates/appdata.xml.in
2016-06-09 22:57:51 +02:00
cmake/templates/doxygen.in
2016-09-11 21:02:20 +02:00
cmake/templates/global.h.in
cmake/templates/template.pc.in
)
set(SCRIPT_FILES
)
if(MINGW)
list(APPEND CMAKE_TEMPLATE_FILES
cmake/templates/windows.rc.in
)
list(APPEND SCRIPT_FILES
scripts/wine.sh
)
endif()
set(DOC_FILES
README.md
2017-03-12 20:23:21 +01:00
doc/buildvariables.md
doc/testapplication.md
)
set(EXTRA_FILES
tests/calculateoverallcoverage.awk
coding-style.clang-format
)
# required to include CMake modules from own project directory
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_MODULE_PATH}")
2015-12-05 22:47:49 +01:00
# meta data
set(META_PROJECT_NAME c++utilities)
set(META_PROJECT_VARNAME CPP_UTILITIES)
2015-12-05 22:47:49 +01:00
set(META_APP_NAME "C++ Utilities")
set(META_APP_AUTHOR "Martchus")
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
2017-11-04 15:48:47 +01:00
set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities")
set(META_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local)
2016-05-01 20:09:20 +02:00
set(META_VERSION_MAJOR 4)
set(META_VERSION_MINOR 15)
set(META_VERSION_PATCH 1)
2015-12-05 22:47:49 +01:00
2016-07-27 18:16:51 +02:00
# find required 3rd party libraries
include(3rdParty)
use_iconv(AUTO_LINKAGE REQUIRED)
2016-07-27 18:16:51 +02:00
# configure use of native file buffer and its backend implementation if enabled
option(USE_NATIVE_FILE_BUFFER "enables use of native file buffer, affects ABI" OFF)
option(FORCE_BOOST_IOSTREAMS_FOR_NATIVE_FILE_BUFFER "forces use of Boost.Iostreams for native file buffer" OFF)
if(USE_NATIVE_FILE_BUFFER)
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_NATIVE_FILE_BUFFER)
# check whether __gnu_cxx::stdio_filebuf is available
try_compile(GNU_CXX_STDIO_FILEBUF_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/feature_detection/stdio_filebuf.cpp
OUTPUT_VARIABLE GNU_CXX_STDIO_FILEBUF_CHECK_LOG
)
# use __gnu_cxx::stdio_filebuf if available or fallback to boost::iostreams::stream_buffer
if(GNU_CXX_STDIO_FILEBUF_AVAILABLE AND NOT FORCE_BOOST_IOSTREAMS_FOR_NATIVE_FILE_BUFFER)
message(STATUS "Using __gnu_cxx::stdio_filebuf for NativeFileStream")
set_source_files_properties(
io/nativefilestream.cpp
PROPERTIES COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_GNU_CXX_STDIO_FILEBUF
)
else()
message(STATUS "Using boost::iostreams::stream_buffer<boost::iostreams::file_descriptor_sink> for NativeFileStream")
use_external_library(boost_iostreams AUTO_LINKAGE REQUIRED)
set_source_files_properties(
io/nativefilestream.cpp
PROPERTIES COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_BOOST_IOSTREAMS
)
endif()
else()
message(STATUS "Using std::fstream for NativeFileStream")
endif()
2016-12-24 16:08:09 +01:00
# configure forcing UTF-8 code page under Windows
2017-07-11 20:27:23 +02:00
option(FORCE_UTF8_CODEPAGE "forces use of UTF-8 code page under Windows via ApplicationUtilities::startConsole()" OFF)
2016-12-24 16:08:09 +01:00
if(FORCE_UTF8_CODEPAGE)
list(APPEND META_PRIVATE_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_FORCE_UTF8_CODEPAGE)
endif()
2017-10-17 00:00:46 +02:00
# configure whether escape codes should be enabled by default
option(ENABLE_ESCAPE_CODES_BY_DEAULT "enables usage of escape codes by default" ON)
if(ENABLE_ESCAPE_CODES_BY_DEAULT)
set_source_files_properties(
application/argumentparser.cpp
io/ansiescapecodes.cpp
2018-01-29 16:23:10 +01:00
tests/argumentparsertests.cpp
2017-10-17 00:00:46 +02:00
PROPERTIES COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_ESCAPE_CODES_ENABLED_BY_DEFAULT
)
else()
message(STATUS "Disabling use of escape codes by default.")
endif()
# configure use of thread_local
option(ENABLE_THREAD_LOCAL "enables use of Thread-Local Storage" ON)
if(NOT ENABLE_THREAD_LOCAL)
set_source_files_properties(
conversion/stringconversion.cpp
PROPERTIES COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_NO_THREAD_LOCAL
)
endif()
# include modules to apply configuration
include(BasicConfig)
include(WindowsResources)
include(LibraryTarget)
include(TestTarget)
2016-06-09 22:57:51 +02:00
include(Doxygen)
2016-07-27 21:38:40 +02:00
include(ConfigHeader)