0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 08:01:51 +08:00

Cross-compiler way of C++11 standard requirement (NOTICE: Need to test on Unix systems)

This commit is contained in:
Victor Zarubkin 2017-02-08 21:47:20 +03:00
parent c3c9ac8250
commit c0a23866ed
3 changed files with 37 additions and 15 deletions

View File

@ -1,4 +1,5 @@
project(easy_profiler)
cmake_minimum_required(VERSION 2.8)
project(easy_profiler CXX)
IF (NOT DEFINED LIB_NAME)
SET(LIB_NAME ${PROJECT_NAME})
@ -143,14 +144,6 @@ add_definitions(
#-DEASY_PROFILER_API_DISABLED # uncomment this to disable profiler api only (you will have to rebuild only easy_profiler)
)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (UNIX)
set (CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
endif (UNIX)
else ()
set (CMAKE_CXX_STANDARD 11)
endif (CMAKE_VERSION VERSION_LESS "3.1")
if(WIN32)
add_definitions(
-D_WINSOCK_DEPRECATED_NO_WARNINGS
@ -160,6 +153,17 @@ endif(WIN32)
add_library(${LIB_NAME} SHARED ${SOURCES} resources.rc)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
endif (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
else ()
set_target_properties(${LIB_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
endif (CMAKE_VERSION VERSION_LESS "3.1")
if(UNIX)
set(PLATFORM_LIBS pthread)
endif(UNIX)

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
project(profiler_gui)
project(profiler_gui CXX)
#set(CMAKE_PREFIX_PATH f:/qt/5.5/5.6/msvc2013_64/lib/cmake)
@ -58,6 +58,17 @@ add_executable(${PROJECT_NAME}
resources.rc
)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
endif (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
else ()
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
endif (CMAKE_VERSION VERSION_LESS "3.1")
if(UNIX)
set(SPECIAL_LIB pthread)
endif(UNIX)

View File

@ -1,5 +1,5 @@
project(profiler_sample)
cmake_minimum_required(VERSION 2.8)
project(profiler_sample CXX)
set(CPP_FILES
main.cpp
@ -14,10 +14,6 @@ include_directories(
)
link_directories(${CMAKE_SOURCE_DIR}/../bin)
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif(UNIX)
add_executable(${PROJECT_NAME} ${SOURCES})
set(DISABLED_PROFILER_NAME
@ -32,4 +28,15 @@ endif(UNIX)
target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB})
target_link_libraries(${DISABLED_PROFILER_NAME} easy_profiler ${SPEC_LIB})
if (CMAKE_VERSION VERSION_LESS "3.1")
if (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
else ()
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
endif (CMAKE_VERSION VERSION_LESS "3.1")
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_WITH_EASY_PROFILER)