From b755c24804544e1c3f267b476cbc55b6c76b1d30 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Tue, 17 Feb 2015 10:47:49 +0100 Subject: [PATCH] - Disable annoying VS warnings - Option to enable multiprocessor build on VS - Move all options to CMake: - Unicode - Platform specs --- CMakeLists.txt | 53 ++++++++++++++++++++++++++++++++++++++++-- build/cmake/config.hpp | 34 +-------------------------- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c85b7303..5eaf24ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,56 @@ project(nana) cmake_minimum_required(VERSION 2.8) -#find dependencies + +#Select platform automatically +if(WIN32) + add_definitions(-DNANA_WINDOWS) + add_definitions(-DPLATFORM_SPEC_HPP=) + + #Test if it is MINGW + if(MINGW) + add_definitions(-DNANA_MINGW) + add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) + option(NANA_THREAD_NOT_SUPPORTED "Use this flag if MinGW version is older than 4.8.1" ON) + if(NANA_THREAD_NOT_SUPPORTED) + add_definitions(-DSTD_THREAD_NOT_SUPPORTED) + endif() + endif() +endif() +if(UNIX) + add_definitions(-DNANA_LINUX) + add_definitions(-DNANA_X11) + add_definitions(-DPLATFORM_SPEC_HPP=) + add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) +endif() + + +#Global MSVC definitions +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) + 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() + + +#Find PNG if(UNIX) find_package(Freetype) if (FREETYPE_FOUND) @@ -29,7 +78,7 @@ endif() -#copy our new config.hpp (with removed PNG defines) +#Copy our new config.hpp (with removed defines) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/build/cmake/config.hpp ${CMAKE_SOURCE_DIR}/include/nana/) diff --git a/build/cmake/config.hpp b/build/cmake/config.hpp index 1436e7dc..08527a55 100644 --- a/build/cmake/config.hpp +++ b/build/cmake/config.hpp @@ -13,38 +13,6 @@ #ifndef NANA_CONFIG_HPP #define NANA_CONFIG_HPP -//Select platform automatically -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -//Windows: - #define NANA_WINDOWS 1 - #define PLATFORM_SPEC_HPP - - //Test if it is MINGW - #if defined(__MINGW32__) - #define NANA_MINGW - #define STD_CODECVT_NOT_SUPPORTED - //#define STD_THREAD_NOT_SUPPORTED //Use this flag if MinGW version is older than 4.8.1 - #endif -#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) -//Linux: - #define NANA_LINUX 1 - #define NANA_X11 1 - #define PLATFORM_SPEC_HPP - #define STD_CODECVT_NOT_SUPPORTED -#endif - -//Here defines some flags that tell Nana what features will be supported. - -#define NANA_UNICODE - -#if defined(NANA_UNICODE) && defined(NANA_WINDOWS) - #ifndef _UNICODE - #define _UNICODE - #endif - - #ifndef UNICODE - #define UNICODE - #endif -#endif +//All defines have been moved to the CMakelists.txt in the root directory. #endif //NANA_CONFIG_HPP