simplify automatic project generation

This commit is contained in:
qPCR4vir 2015-12-02 08:39:10 +01:00
parent 3a04e10d69
commit 4b57b76ffb
5 changed files with 43 additions and 81 deletions

View File

@ -4,47 +4,16 @@
# Robert Hauck - Enable support for PNG/Freetype
# Qiangqiang Wu - Add biicode support
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()
if(BIICODE)
# prepare BII_LIB_SRC
set(LIB_SRC ${BII_LIB_SRC})
add_biicode_targets()
@ -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=<nana/detail/win32/platform_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=<nana/detail/macos_X11/platform_spec.hpp>)
#add_definitions(-DPLATFORM_SPEC_HPP=<nana/detail/macos_X11/platform_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=<nana/detail/linux_X11/platform_spec.hpp>)
#add_definitions(-DPLATFORM_SPEC_HPP=<nana/detail/linux_X11/platform_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)

View File

@ -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

View File

@ -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

View File

@ -13,6 +13,9 @@
*
* http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt
*/
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#include <nana/detail/platform_spec_selector.hpp>
#include <X11/Xlocale.h>
#include <locale>
@ -1411,3 +1414,7 @@ namespace detail
}
}//end namespace detail
}//end namespace nana
//#if defined(NANA_LINUX) || defined(NANA_MACOS)
#endif

View File

@ -11,6 +11,9 @@
*
* This file provides basis class and data structrue that required by nana
*/
#if defined(NANA_WINDOWS)
#include <nana/detail/platform_spec_selector.hpp>
#include <shellapi.h>
#include <stdexcept>
@ -289,3 +292,6 @@ namespace detail
}
}//end namespace detail
}//end namespace nana
//#if defined(NANA_WINDOWS)
#endif