From e25a17030d601964239afb8daed3f8d61d83acaa Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Sat, 26 Sep 2015 11:11:23 +0200 Subject: [PATCH] integrated CMake improvements from develop (GH #946) --- CMakeLists.txt | 101 ++++---------- CppParser/CMakeLists.txt | 1 + CppUnit/CMakeLists.txt | 1 + CppUnit/WinTestRunner/CMakeLists.txt | 1 + Crypto/CMakeLists.txt | 1 + Data/CMakeLists.txt | 1 + Data/MySQL/CMakeLists.txt | 1 + Data/ODBC/CMakeLists.txt | 1 + Data/SQLite/CMakeLists.txt | 1 + Foundation/CMakeLists.txt | 190 +++++++++++++++++---------- Foundation/samples/CMakeLists.txt | 1 + JSON/CMakeLists.txt | 1 + MongoDB/CMakeLists.txt | 1 + Net/CMakeLists.txt | 1 + NetSSL_OpenSSL/CMakeLists.txt | 1 + NetSSL_Win/CMakeLists.txt | 1 + PDF/CMakeLists.txt | 1 + SevenZip/CMakeLists.txt | 1 + Util/CMakeLists.txt | 1 + XML/CMakeLists.txt | 1 + XML/samples/CMakeLists.txt | 1 + Zip/CMakeLists.txt | 1 + cmake/DefinePlatformSpecifc.cmake | 122 +++++++++++++++++ cmake/FindMySQL.cmake | 5 + cmake/PocoMacros.cmake | 31 ++++- 25 files changed, 324 insertions(+), 145 deletions(-) create mode 100644 cmake/DefinePlatformSpecifc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c17cb1f1..abf9507cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,14 +6,14 @@ # ENABLE_{COMPONENT} # ENABLE_TESTS -project(Poco) - cmake_minimum_required(VERSION 3.0.0) -file(STRINGS "${CMAKE_SOURCE_DIR}/libversion" SHARED_LIBRARY_VERSION) +project(Poco) + +file(STRINGS "${PROJECT_SOURCE_DIR}/libversion" SHARED_LIBRARY_VERSION) # Read the version information from the VERSION file -file (STRINGS "${CMAKE_SOURCE_DIR}/VERSION" PACKAGE_VERSION ) +file (STRINGS "${PROJECT_SOURCE_DIR}/VERSION" PACKAGE_VERSION ) message(STATUS "Poco package version: ${PACKAGE_VERSION}") string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION}) string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION}) @@ -35,6 +35,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # Append our module directory to CMake set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +# COMMENT REPLACED BY BIICODE + ################################################################################# # Setup C/C++ compiler options ################################################################################# @@ -49,20 +51,7 @@ endif() if (CMAKE_BUILD_TYPE STREQUAL "") set( CMAKE_BUILD_TYPE "RelWithDebInfo" ) -endif () - -# http://www.cmake.org/Wiki/CMake_Useful_Variables : -# CMAKE_BUILD_TYPE -# Choose the type of build. CMake has default flags for these: -# -# * None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used) -# * Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG) -# * Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE) -# * RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO -# * MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL) - -# For Debug build types, append a "d" to the library names. -set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE) +endif() # Include some common macros to simpilfy the Poco CMake files include(PocoMacros) @@ -100,13 +89,22 @@ option(POCO_STATIC option(POCO_UNBUNDLED "Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF) -# Uncomment from next two lines to force statitc or dynamic library, default is autodetection +if(MSVC) + option(POCO_MT + "Set to OFF|ON (default is OFF) to control build of POCO as /MT instead of /MD" OFF) + + option(ENABLE_MSVC_MP + "Set to OFF|ON (default is OFF) to control parallel build of POCO with MSVC" OFF) +endif() + +# Uncomment from next two lines to force static or dynamic library, default is autodetection if(POCO_STATIC) - add_definitions( -DPOCO_STATIC -DPOCO_NO_AUTOMATIC_LIBS) + set( LIB_MODE_DEFINITIONS -DPOCO_STATIC -DPOCO_NO_AUTOMATIC_LIBS) set( LIB_MODE STATIC ) message(STATUS "Building static libraries") else(POCO_STATIC) set( LIB_MODE SHARED ) + set( LIB_MODE_DEFINITIONS -DPOCO_NO_AUTOMATIC_LIBS) message(STATUS "Building dynamic libraries") endif(POCO_STATIC) @@ -125,58 +123,7 @@ else () message(STATUS "Build with using internal copy of sqlite, libz, pcre, expat, ...") endif () -include(CheckTypeSize) -find_package(Cygwin) - -# OS Detection -if(WIN32) - add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE) - #set(SYSLIBS iphlpapi gdi32 odbc32) -endif(WIN32) - -if (UNIX AND NOT ANDROID ) - add_definitions( -DPOCO_OS_FAMILY_UNIX ) - # Standard 'must be' defines - if (APPLE) - add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64) - set(SYSLIBS dl) - else (APPLE) - add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) - set(SYSLIBS pthread dl rt) - endif (APPLE) -endif(UNIX AND NOT ANDROID ) - -if (CMAKE_SYSTEM MATCHES "SunOS") - add_definitions( -DPOCO_OS_FAMILY_UNIX ) - # Standard 'must be' defines - add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ) - set(SYSLIBS pthread socket xnet nsl resolv rt dl) -endif(CMAKE_SYSTEM MATCHES "SunOS") - -if (CMAKE_COMPILER_IS_MINGW) - add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) - add_definitions(-D_WIN32 -DMINGW32 -DWINVER=0x500 -DODBCVER=0x0300 -DPOCO_THREAD_STACK_SIZE) -endif (CMAKE_COMPILER_IS_MINGW) - -if (CYGWIN) -# add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) -endif (CYGWIN) - -# SunPro C++ -if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") - add_definitions( -D_BSD_SOURCE -library=stlport4) -endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") - -# iOS -if (IOS) - add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES ) -endif(IOS) - -#Android -if (ANDROID) - add_definitions( -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY ) -endif(ANDROID) - +include(DefinePlatformSpecifc) # Collect the built libraries and include dirs, the will be used to create the PocoConfig.cmake file set(Poco_COMPONENTS "") @@ -328,7 +275,17 @@ message(STATUS "CMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} u message(STATUS "Installation target path: ${CMAKE_INSTALL_PREFIX}") message(STATUS "C_FLAGS: =${CMAKE_C_FLAGS}") +message(STATUS "CMAKE_C_FLAGS_DEBUG:=${CMAKE_C_FLAGS_DEBUG}") +message(STATUS "CMAKE_C_FLAGS_RELEASE:=${CMAKE_C_FLAGS_RELEASE}") +message(STATUS "CMAKE_C_FLAGS_MINSIZEREL:=${CMAKE_C_FLAGS_MINSIZEREL}") +message(STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO:=${CMAKE_C_FLAGS_RELWITHDEBINFO}") +message(STATUS "") +message(STATUS "") message(STATUS "CXX_FLAGS:=${CMAKE_CXX_FLAGS}") +message(STATUS "CMAKE_CXX_FLAGS_DEBUG:=${CMAKE_CXX_FLAGS_DEBUG}") +message(STATUS "CMAKE_CXX_FLAGS_RELEASE:=${CMAKE_CXX_FLAGS_RELEASE}") +message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL:=${CMAKE_CXX_FLAGS_MINSIZEREL}") +message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO:=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") foreach(component ${Poco_COMPONENTS}) message(STATUS "Building: ${component}") diff --git a/CppParser/CMakeLists.txt b/CppParser/CMakeLists.txt index fe52d3a42..0c970c8e7 100644 --- a/CppParser/CMakeLists.txt +++ b/CppParser/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/CppUnit/CMakeLists.txt b/CppUnit/CMakeLists.txt index 5ab587bc0..eafded440 100644 --- a/CppUnit/CMakeLists.txt +++ b/CppUnit/CMakeLists.txt @@ -20,3 +20,4 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) diff --git a/CppUnit/WinTestRunner/CMakeLists.txt b/CppUnit/WinTestRunner/CMakeLists.txt index 541233bc8..27416cb8d 100644 --- a/CppUnit/WinTestRunner/CMakeLists.txt +++ b/CppUnit/WinTestRunner/CMakeLists.txt @@ -27,6 +27,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) if(WIN32) target_link_libraries( ${LIBNAME} winmm ) diff --git a/Crypto/CMakeLists.txt b/Crypto/CMakeLists.txt index 7f4c2621b..ea948be79 100644 --- a/Crypto/CMakeLists.txt +++ b/Crypto/CMakeLists.txt @@ -27,6 +27,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index e96cf3eb5..ab77443cf 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -34,6 +34,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Data/MySQL/CMakeLists.txt b/Data/MySQL/CMakeLists.txt index 254135be5..510c6cb77 100644 --- a/Data/MySQL/CMakeLists.txt +++ b/Data/MySQL/CMakeLists.txt @@ -27,6 +27,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Data/ODBC/CMakeLists.txt b/Data/ODBC/CMakeLists.txt index eb29288a8..67d2d955f 100644 --- a/Data/ODBC/CMakeLists.txt +++ b/Data/ODBC/CMakeLists.txt @@ -27,6 +27,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Data/SQLite/CMakeLists.txt b/Data/SQLite/CMakeLists.txt index a7a5bf574..6509421ee 100644 --- a/Data/SQLite/CMakeLists.txt +++ b/Data/SQLite/CMakeLists.txt @@ -48,6 +48,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index c1dd25ff4..425c9f6d7 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -19,14 +19,14 @@ POCO_HEADERS_AUTO( SRCS include/Poco/SyslogChannel.h ) # For Windows CE we need to disable these if(WINCE) POCO_SOURCES_AUTO_PLAT( SRCS OFF - src/WindowsConsoleChannel.cpp - src/EventLogChannel.cpp - ) + src/WindowsConsoleChannel.cpp + src/EventLogChannel.cpp + ) else() POCO_SOURCES_AUTO_PLAT( SRCS WIN32 - src/WindowsConsoleChannel.cpp - src/EventLogChannel.cpp - ) + src/WindowsConsoleChannel.cpp + src/EventLogChannel.cpp + ) endif() # Messages @@ -35,97 +35,143 @@ POCO_MESSAGES( SRCS Logging src/pocomsg.mc) # If POCO_UNBUNDLED is enabled we try to find the required packages # The configuration will fail if the packages are not found if (POCO_UNBUNDLED) - find_package(PCRE REQUIRED) - set(SYSLIBS ${SYSLIBS} ${PCRE_LIBRARIES}) - include_directories(${PCRE_INCLUDE_DIRS}) + find_package(PCRE REQUIRED) + set(SYSLIBS ${SYSLIBS} ${PCRE_LIBRARIES}) + include_directories(${PCRE_INCLUDE_DIRS}) - #HACK: Unicode.cpp requires functions from these files. The can't be taken from the library - POCO_SOURCES( SRCS RegExp - src/pcre_ucd.c - src/pcre_tables.c - ) + #HACK: Unicode.cpp requires functions from these files. The can't be taken from the library + POCO_SOURCES( SRCS RegExp + src/pcre_ucd.c + src/pcre_tables.c + ) - find_package(ZLIB REQUIRED) - set(SYSLIBS ${SYSLIBS} ${ZLIB_LIBRARIES}) - include_directories(${ZLIB_INCLUDE_DIRS}) + find_package(ZLIB REQUIRED) + set(SYSLIBS ${SYSLIBS} ${ZLIB_LIBRARIES}) + include_directories(${ZLIB_INCLUDE_DIRS}) else() - # pcre - POCO_SOURCES( SRCS pcre - src/pcre_config.c - src/pcre_byte_order.c - src/pcre_chartables.c - src/pcre_compile.c - src/pcre_exec.c - src/pcre_fullinfo.c - src/pcre_globals.c - src/pcre_maketables.c - src/pcre_newline.c - src/pcre_ord2utf8.c - src/pcre_study.c - src/pcre_tables.c - src/pcre_dfa_exec.c - src/pcre_get.c - src/pcre_jit_compile.c - src/pcre_refcount.c - src/pcre_string_utils.c - src/pcre_version.c - src/pcre_ucd.c - src/pcre_valid_utf8.c - src/pcre_xclass.c - ) + # pcre + POCO_SOURCES( SRCS pcre + src/pcre_config.c + src/pcre_byte_order.c + src/pcre_chartables.c + src/pcre_compile.c + src/pcre_exec.c + src/pcre_fullinfo.c + src/pcre_globals.c + src/pcre_maketables.c + src/pcre_newline.c + src/pcre_ord2utf8.c + src/pcre_study.c + src/pcre_tables.c + src/pcre_dfa_exec.c + src/pcre_get.c + src/pcre_jit_compile.c + src/pcre_refcount.c + src/pcre_string_utils.c + src/pcre_version.c + src/pcre_ucd.c + src/pcre_valid_utf8.c + src/pcre_xclass.c + ) - # zlib - POCO_HEADERS( SRCS zlib - include/Poco/zconf.h - include/Poco/zlib.h - ) + # zlib + POCO_HEADERS( SRCS zlib + include/Poco/zconf.h + include/Poco/zlib.h + ) - POCO_SOURCES( SRCS zlib - src/adler32.c - src/compress.c - src/crc32.c - src/deflate.c - src/infback.c - src/inffast.c - src/inflate.c - src/inftrees.c - src/trees.c - src/zutil.c - ) + POCO_SOURCES( SRCS zlib + src/adler32.c + src/compress.c + src/crc32.c + src/deflate.c + src/infback.c + src/inffast.c + src/inflate.c + src/inftrees.c + src/trees.c + src/zutil.c + ) endif (POCO_UNBUNDLED) if(WIN32) - set(SYSLIBS ${SYSLIBS} iphlpapi) + set(SYSLIBS ${SYSLIBS} iphlpapi) endif(WIN32) if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") - set_target_properties( "${LIBNAME}" PROPERTIES LINK_FLAGS "-library=stlport4") + set_target_properties( "${LIBNAME}" PROPERTIES LINK_FLAGS "-library=stlport4") endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") +if(ANDROID) + set(SYSLIBS ${SYSLIBS} log) +endif(ANDROID) + # TODO: Why is this here? add_definitions( -DPCRE_STATIC) +# For SetAffinity +if(UNIX AND NOT APPLE) + INCLUDE (CheckFunctionExists) + INCLUDE (CheckCXXSourceCompiles) + INCLUDE (CheckLibraryExists) + CHECK_LIBRARY_EXISTS(pthread pthread_setaffinity_np "pthread.h" HAVE_PTHREAD_SETAFFINITY_NP) + #set(CMAKE_EXTRA_INCLUDE_FILES pthread.h) + #CHECK_FUNCTION_EXISTS(pthread_setaffinity_np HAVE_PTHREAD_SETAFFINITY_NP) + if(NOT HAVE_PTHREAD_SETAFFINITY_NP) + message(STATUS "Platform has not PTHREAD_SETAFFINITY_NP") + else(HAVE_PTHREAD_SETAFFINITY_NP) + add_definitions(-DHAVE_PTHREAD_SETAFFINITY_NP) + CHECK_CXX_SOURCE_COMPILES(" + #include + int main() { + cpu_set_t cpumask; + sched_setaffinity( 0, sizeof(cpumask), &cpumask ); + return 0; + }" HAVE_THREE_PARAM_SCHED_SETAFFINITY) + + if(HAVE_THREE_PARAM_SCHED_SETAFFINITY) + message(STATUS "Platform has THREE PARAM at PTHREAD_SETAFFINITY_NP") + add_definitions(-DHAVE_THREE_PARAM_SCHED_SETAFFINITY) + else(HAVE_THREE_PARAM_SCHED_SETAFFINITY) + CHECK_CXX_SOURCE_COMPILES(" + #include + int main() { + cpu_set_t cpumask; + sched_setaffinity( 0, &cpumask ); + return 0; + }" HAVE_TWO_PARAM_SCHED_SETAFFINITY) + + if(HAVE_TWO_PARAM_SCHED_SETAFFINITY) + message(STATUS "Platform has TWO PARAM at PTHREAD_SETAFFINITY_NP") + add_definitions(-DHAVE_TWO_PARAM_SCHED_SETAFFINITY) + endif(HAVE_TWO_PARAM_SCHED_SETAFFINITY) + + endif(HAVE_THREE_PARAM_SCHED_SETAFFINITY) + endif(NOT HAVE_PTHREAD_SETAFFINITY_NP) +endif(UNIX AND NOT APPLE) + add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS}) add_library( "${POCO_LIBNAME}" ALIAS "${LIBNAME}") set_target_properties( "${LIBNAME}" - PROPERTIES - VERSION ${PROJECT_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION} - OUTPUT_NAME ${POCO_LIBNAME} - DEFINE_SYMBOL Foundation_EXPORTS - ) + PROPERTIES + VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION} + OUTPUT_NAME ${POCO_LIBNAME} + DEFINE_SYMBOL Foundation_EXPORTS + ) target_link_libraries( "${LIBNAME}" ${SYSLIBS}) target_include_directories( "${LIBNAME}" - PUBLIC - $ - $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - ) + PUBLIC + $ + $ + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src + ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory( samples ) - add_subdirectory( testsuite ) + add_subdirectory( samples ) + add_subdirectory( testsuite ) endif () diff --git a/Foundation/samples/CMakeLists.txt b/Foundation/samples/CMakeLists.txt index cc82eb299..f50e3a60a 100644 --- a/Foundation/samples/CMakeLists.txt +++ b/Foundation/samples/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(ActiveMethod) add_subdirectory(Activity) +add_subdirectory(Benchmark) add_subdirectory(BinaryReaderWriter) add_subdirectory(DateTime) add_subdirectory(LogRotation) diff --git a/JSON/CMakeLists.txt b/JSON/CMakeLists.txt index e5746a628..9f73e0376 100644 --- a/JSON/CMakeLists.txt +++ b/JSON/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/MongoDB/CMakeLists.txt b/MongoDB/CMakeLists.txt index 5b95e6254..e9f443026 100644 --- a/MongoDB/CMakeLists.txt +++ b/MongoDB/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Net/CMakeLists.txt b/Net/CMakeLists.txt index af19c0487..e6ef2636f 100644 --- a/Net/CMakeLists.txt +++ b/Net/CMakeLists.txt @@ -34,6 +34,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/NetSSL_OpenSSL/CMakeLists.txt b/NetSSL_OpenSSL/CMakeLists.txt index f6a40c68d..b6e376a21 100644 --- a/NetSSL_OpenSSL/CMakeLists.txt +++ b/NetSSL_OpenSSL/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/NetSSL_Win/CMakeLists.txt b/NetSSL_Win/CMakeLists.txt index 355f49baf..6a9b13297 100644 --- a/NetSSL_Win/CMakeLists.txt +++ b/NetSSL_Win/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/PDF/CMakeLists.txt b/PDF/CMakeLists.txt index 46f538d77..3ecb9574a 100644 --- a/PDF/CMakeLists.txt +++ b/PDF/CMakeLists.txt @@ -130,6 +130,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/SevenZip/CMakeLists.txt b/SevenZip/CMakeLists.txt index bf76be324..fd13ee3a9 100644 --- a/SevenZip/CMakeLists.txt +++ b/SevenZip/CMakeLists.txt @@ -66,6 +66,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Util/CMakeLists.txt b/Util/CMakeLists.txt index 4bd083f58..a367f12ea 100644 --- a/Util/CMakeLists.txt +++ b/Util/CMakeLists.txt @@ -42,6 +42,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/XML/CMakeLists.txt b/XML/CMakeLists.txt index 21e57f825..d0410781c 100644 --- a/XML/CMakeLists.txt +++ b/XML/CMakeLists.txt @@ -48,6 +48,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/XML/samples/CMakeLists.txt b/XML/samples/CMakeLists.txt index 659591ff6..7df6ecf42 100644 --- a/XML/samples/CMakeLists.txt +++ b/XML/samples/CMakeLists.txt @@ -2,4 +2,5 @@ add_subdirectory(DOMParser) add_subdirectory(DOMWriter) add_subdirectory(PrettyPrint) add_subdirectory(SAXParser) +#add_subdirectory(RoundTrip) diff --git a/Zip/CMakeLists.txt b/Zip/CMakeLists.txt index 1263d283d..5054baad1 100644 --- a/Zip/CMakeLists.txt +++ b/Zip/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/cmake/DefinePlatformSpecifc.cmake b/cmake/DefinePlatformSpecifc.cmake new file mode 100644 index 000000000..dec45e5d6 --- /dev/null +++ b/cmake/DefinePlatformSpecifc.cmake @@ -0,0 +1,122 @@ +# http://www.cmake.org/Wiki/CMake_Useful_Variables : +# CMAKE_BUILD_TYPE +# Choose the type of build. CMake has default flags for these: +# +# * None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used) +# * Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG) +# * Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE) +# * RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO +# * MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL) + +# Setting CXX Flag /MD or /MT and POSTFIX values i.e MDd / MD / MTd / MT / d +# +# For visual studio the library naming is as following: +# Dynamic libraries: +# - PocoX.dll for release library +# - PocoXd.dll for debug library +# +# Static libraries: +# - PocoXmd.lib for /MD release build +# - PocoXtmt.lib for /MT release build +# +# - PocoXmdd.lib for /MD debug build +# - PocoXmtd.lib for /MT debug build + +if(MSVC) + if(POCO_MT) + set(CompilerFlags + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_FLAGS + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE + ) + foreach(CompilerFlag ${CompilerFlags}) + string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") + endforeach() + + set(STATIC_POSTFIX "mt" CACHE STRING "Set static library postfix" FORCE) + else(POCO_MT) + set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE) + endif(POCO_MT) + + if (ENABLE_MSVC_MP) + add_definitions(/MP) + endif() + +else(MSVC) + # Other compilers then MSVC don't have a static STATIC_POSTFIX at the moment + set(STATIC_POSTFIX "" CACHE STRING "Set static library postfix" FORCE) +endif(MSVC) + +# Add a d postfix to the debug libraries +if(POCO_STATIC) + set(CMAKE_DEBUG_POSTFIX "${STATIC_POSTFIX}d" CACHE STRING "Set Debug library postfix" FORCE) + set(CMAKE_RELEASE_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set Release library postfix" FORCE) + set(CMAKE_MINSIZEREL_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set MinSizeRel library postfix" FORCE) + set(CMAKE_RELWITHDEBINFO_POSTFIX "${STATIC_POSTFIX}d" CACHE STRING "Set RelWithDebInfo library postfix" FORCE) +else(POCO_STATIC) + set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set Debug library postfix" FORCE) + set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set Release library postfix" FORCE) + set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "Set MinSizeRel library postfix" FORCE) + set(CMAKE_RELWITHDEBINFO_POSTFIX "d" CACHE STRING "Set RelWithDebInfo library postfix" FORCE) +endif() + + +# OS Detection +include(CheckTypeSize) +find_package(Cygwin) + +if(WIN32) + add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE -D__LCC__) #__LCC__ define used by MySQL.h +endif(WIN32) + +if (UNIX AND NOT ANDROID ) + add_definitions( -DPOCO_OS_FAMILY_UNIX ) + # Standard 'must be' defines + if (APPLE) + add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64) + set(SYSLIBS dl) + else (APPLE) + add_definitions( -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ) + if (QNX) + add_definitions( -DPOCO_HAVE_FD_POLL) + set(SYSLIBS m socket) + else (QNX) + add_definitions( -D_XOPEN_SOURCE=500 -DPOCO_HAVE_FD_EPOLL) + set(SYSLIBS pthread dl rt) + endif (QNX) + endif (APPLE) +endif(UNIX AND NOT ANDROID ) + +if (CMAKE_SYSTEM MATCHES "SunOS") + add_definitions( -DPOCO_OS_FAMILY_UNIX ) + # Standard 'must be' defines + add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ) + set(SYSLIBS pthread socket xnet nsl resolv rt dl) +endif(CMAKE_SYSTEM MATCHES "SunOS") + +if (CMAKE_COMPILER_IS_MINGW) + add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) + add_definitions(-D_WIN32 -DMINGW32 -DWINVER=0x500 -DODBCVER=0x0300 -DPOCO_THREAD_STACK_SIZE) +endif (CMAKE_COMPILER_IS_MINGW) + +if (CYGWIN) +# add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) +endif (CYGWIN) + +# SunPro C++ +if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") + add_definitions( -D_BSD_SOURCE -library=stlport4) +endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") + +# iOS +if (IOS) + add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES ) +endif(IOS) + +#Android +if (ANDROID) + add_definitions( -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY ) +endif(ANDROID) diff --git a/cmake/FindMySQL.cmake b/cmake/FindMySQL.cmake index c8a9b1b8c..64763d8bb 100644 --- a/cmake/FindMySQL.cmake +++ b/cmake/FindMySQL.cmake @@ -1,3 +1,6 @@ +SET(BINDIR32_ENV_NAME "ProgramFiles(x86)") +SET(BINDIR32 $ENV{${BINDIR32_ENV_NAME}}) + find_path(MYSQL_INCLUDE_DIR mysql.h /usr/include/mysql /usr/local/include/mysql @@ -8,6 +11,7 @@ find_path(MYSQL_INCLUDE_DIR mysql.h $ENV{MYSQL_INCLUDE_DIR} $ENV{MYSQL_DIR}/include $ENV{ProgramFiles}/MySQL/*/include + ${BINDIR32}/MySQL/include $ENV{SystemDrive}/MySQL/*/include) if (WIN32) @@ -26,6 +30,7 @@ if (WIN32) $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild} $ENV{MYSQL_DIR}/client/${libsuffixBuild} $ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist} + ${BINDIR32}/MySQL/lib $ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist}) else (WIN32) find_library(MYSQL_LIB NAMES mysqlclient_r diff --git a/cmake/PocoMacros.cmake b/cmake/PocoMacros.cmake index 6f3dfed49..5d42c6957 100644 --- a/cmake/PocoMacros.cmake +++ b/cmake/PocoMacros.cmake @@ -16,15 +16,18 @@ if (WIN32) # be set up anyway get_filename_component(sdk_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" REALPATH) get_filename_component(kit_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot]" REALPATH) + get_filename_component(kit81_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" REALPATH) if (X64) set(sdk_bindir "${sdk_dir}/bin/x64") set(kit_bindir "${kit_dir}/bin/x64") + set(kit81_bindir "${kit81_dir}/bin/x64") else (X64) set(sdk_bindir "${sdk_dir}/bin") set(kit_bindir "${kit_dir}/bin/x86") + set(kit81_bindir "${kit81_dir}/bin/x86") endif (X64) endif () - find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}" + find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}" "${kit81_bindir}" DOC "path to message compiler") if (NOT CMAKE_MC_COMPILER) message(FATAL_ERROR "message compiler not found: required to build") @@ -250,4 +253,30 @@ install( RUNTIME DESTINATION bin INCLUDES DESTINATION include ) + +if (MSVC) +# install the targets pdb + POCO_INSTALL_PDB(${target_name}) +endif() + +endmacro() + +# POCO_INSTALL_PDB - Install the given target's companion pdb file (if present) +# Usage: POCO_INSTALL_PDB(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_INSTALL_PDB(Foundation) +# +# This is an internal macro meant only to be used by POCO_INSTALL. +macro(POCO_INSTALL_PDB target_name) + + get_property(type TARGET ${target_name} PROPERTY TYPE) + if ("${type}" STREQUAL "SHARED_LIBRARY" OR "${type}" STREQUAL "EXECUTABLE") + install( + FILES $ + DESTINATION bin + COMPONENT Devel + OPTIONAL + ) + endif() endmacro()