From 4b57b76ffbcb446a090644713119c2baf9eb67eb Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 2 Dec 2015 08:39:10 +0100 Subject: [PATCH] simplify automatic project generation --- CMakeLists.txt | 99 ++++--------------- .../nana/detail/linux_X11/platform_spec.hpp | 6 ++ include/nana/detail/win32/platform_spec.hpp | 6 ++ source/detail/linux_X11/platform_spec.cpp | 7 ++ source/detail/win32/platform_spec.cpp | 6 ++ 5 files changed, 43 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6453263..b943f95a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,48 +4,17 @@ # Robert Hauck - Enable support for PNG/Freetype # Qiangqiang Wu - Add biicode support + +# set compile flags +if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") +endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + + if(BIICODE) # prepare BII_LIB_SRC set(LIB_SRC ${BII_LIB_SRC}) - foreach(cpp ${BII_LIB_SRC}) - if(${cpp} MATCHES "/detail/(win32|linux_X11)/.+$") - list(APPEND trash_files ${cpp}) - endif() - endforeach() - - list(REMOVE_ITEM BII_LIB_SRC ${trash_files}) - - if(WIN32) - file(GLOB_RECURSE platform_files "*/detail/win32/*") - list(APPEND BII_LIB_SRC ${platform_files}) - elseif(APPLE) - file(GLOB_RECURSE platform_files "*/detail/macos_X11/*") - list(APPEND BII_LIB_SRC ${platform_files}) - elseif(UNIX) - file(GLOB_RECURSE platform_files "*/detail/linux_X11/*") - list(APPEND BII_LIB_SRC ${platform_files}) - else() - message(FATAL_ERROR "Only Windows and Unix are supported for the moment (Mac OS is experimental)") - endif() - - # set compile flags - if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") - endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - - # we'll use the default config file so we can iliminate the following macro definitions - if(MSVC) - # More MSVC specific compilation flags - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - if(MSVC14) - add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) - else() - add_definitions(-DNOT_IMPLEMENTED_KEYWORD_noexcept) - endif() - endif() - add_biicode_targets() return() @@ -54,40 +23,16 @@ endif() project(nana) cmake_minimum_required(VERSION 2.8) -#Select platform automatically -if(WIN32) - add_definitions(-DNANA_WINDOWS) - add_definitions(-DPLATFORM_SPEC_HPP=) - if(MSVC14) - add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) - else() - add_definitions(-DNOT_IMPLEMENTED_KEYWORD_noexcept) - endif() - - #Test if it is MINGW - if(MINGW) - add_definitions(-DNANA_MINGW) - add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.1") - option(NANA_THREAD_NOT_SUPPORTED "Use this flag if MinGW version is older than 4.8.1" ON) - endif() - endif() - if(NANA_THREAD_NOT_SUPPORTED) - add_definitions(-DSTD_THREAD_NOT_SUPPORTED) - endif() - endif() -endif() if(APPLE) add_definitions(-DNANA_MACOS) add_definitions(-DNANA_X11) - add_definitions(-DPLATFORM_SPEC_HPP=) + #add_definitions(-DPLATFORM_SPEC_HPP=) add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) include_directories(/opt/X11/include/) elseif(UNIX) add_definitions(-DNANA_LINUX) add_definitions(-DNANA_X11) - add_definitions(-DPLATFORM_SPEC_HPP=) + #add_definitions(-DPLATFORM_SPEC_HPP=) add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) endif() @@ -96,25 +41,26 @@ endif() if(WIN32) if(MSVC) option(WIN32_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON) + # ?? if(WIN32_USE_MP) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() # More MSVC specific compilation flags - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + #add_definitions(-D_SCL_SECURE_NO_WARNINGS) + #add_definitions(-D_CRT_SECURE_NO_DEPRECATE) endif(MSVC) endif(WIN32) #Unicode option(NANA_UNICODE "Use Unicode Character Set" ON) -if(NANA_UNICODE) - add_definitions(-DNANA_UNICODE) - if(WIN32) - add_definitions(-DUNICODE -D_UNICODE) - endif() -endif() +#if(NANA_UNICODE) +# add_definitions(-DNANA_UNICODE) +# if(WIN32) +# add_definitions(-DUNICODE -D_UNICODE) +# endif() +#endif() #Find PNG if(UNIX) @@ -139,15 +85,6 @@ if(NANA_ENABLE_PNG) endif() endif() -#Copy our new config.hpp (with removed defines) -execute_process(COMMAND ${CMAKE_COMMAND} - -E copy_if_different - ${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/include/nana/) - -if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") -endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source) set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) diff --git a/include/nana/detail/linux_X11/platform_spec.hpp b/include/nana/detail/linux_X11/platform_spec.hpp index 461517f9..0a013ed6 100644 --- a/include/nana/detail/linux_X11/platform_spec.hpp +++ b/include/nana/detail/linux_X11/platform_spec.hpp @@ -13,6 +13,8 @@ * This file should not be included by any header files. */ +#if defined(NANA_LINUX) || defined(NANA_MACOS) + #ifndef NANA_DETAIL_PLATFORM_SPEC_HPP #define NANA_DETAIL_PLATFORM_SPEC_HPP @@ -323,5 +325,9 @@ namespace detail }//end namespace nana +// .h ward +#endif + +//#if defined(NANA_LINUX) || defined(NANA_MACOS) #endif diff --git a/include/nana/detail/win32/platform_spec.hpp b/include/nana/detail/win32/platform_spec.hpp index b0b90fad..b129406b 100644 --- a/include/nana/detail/win32/platform_spec.hpp +++ b/include/nana/detail/win32/platform_spec.hpp @@ -12,6 +12,7 @@ * This file provides basis class and data structrue that required by nana * This file should not be included by any header files. */ +#if defined(NANA_WINDOWS) #ifndef NANA_DETAIL_PLATFORM_SPEC_HPP #define NANA_DETAIL_PLATFORM_SPEC_HPP @@ -198,4 +199,9 @@ namespace detail }//end namespace detail }//end namespace nana + +// .h ward +#endif + +//#if defined(NANA_WINDOWS) #endif diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index d2244430..1f17cda4 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -13,6 +13,9 @@ * * http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt */ + +#if defined(NANA_LINUX) || defined(NANA_MACOS) + #include #include #include @@ -1411,3 +1414,7 @@ namespace detail } }//end namespace detail }//end namespace nana + + +//#if defined(NANA_LINUX) || defined(NANA_MACOS) +#endif diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index ffc6dc28..7b048aba 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -11,6 +11,9 @@ * * This file provides basis class and data structrue that required by nana */ + +#if defined(NANA_WINDOWS) + #include #include #include @@ -289,3 +292,6 @@ namespace detail } }//end namespace detail }//end namespace nana + +//#if defined(NANA_WINDOWS) +#endif \ No newline at end of file