diff --git a/CMakeLists.txt b/CMakeLists.txt index d3ae42fdf..8a12b96be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,19 +234,18 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") - set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") + add_definitions(-DNDEBUG) CHECK_C_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefined) if(Wno-builtin-macro-redefined) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-builtin-macro-redefined") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'") + add_definitions(-D__FILE__="\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"") endif() CHECK_CXX_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefinedCXX) if(Wno-builtin-macro-redefinedCXX) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-builtin-macro-redefined") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'") + add_definitions(-D__FILE__="\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"") endif() else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") @@ -334,9 +333,9 @@ if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_AMD64_") + add_definitions(-D_AMD64_) else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_") + add_definitions(-D_X86_) endif() set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}) @@ -351,10 +350,10 @@ if(MSVC) endif() if(WIN32) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNICODE -D_UNICODE") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WINSOCK_DEPRECATED_NO_WARNINGS") + add_definitions(-DUNICODE -D_UNICODE) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-DWIN32_LEAN_AND_MEAN) + add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) set(CMAKE_USE_RELATIVE_PATH ON) if (${CMAKE_GENERATOR} MATCHES "NMake Makefile*") @@ -378,17 +377,13 @@ if(WIN32) endif() if(CMAKE_WINDOWS_VERSION STREQUAL "WINXP") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0501 -D_WIN32_WINNT=0x0501") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0501 -D_WIN32_WINNT=0x0501") + add_definitions(-DWINVER=0x0501 -D_WIN32_WINNT=0x0501) elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN7") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0601 -D_WIN32_WINNT=0x0601") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0601 -D_WIN32_WINNT=0x0601") + add_definitions(-DWINVER=0x0601 -D_WIN32_WINNT=0x0601) elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN8") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0602 -D_WIN32_WINNT=0x0602") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0602 -D_WIN32_WINNT=0x0602") + add_definitions(-DWINVER=0x0602 -D_WIN32_WINNT=0x0602) elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN10") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00") + add_definitions(-DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00) endif() if (FREERDP_EXTERNAL_SSL_PATH) @@ -400,8 +395,7 @@ if(IOS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isysroot ${CMAKE_IOS_SDK_ROOT} -g") endif() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_EXPORTS -DFREERDP_EXPORTS") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINPR_EXPORTS -DFREERDP_EXPORTS") +add_definitions(-DWINPR_EXPORTS -DFREERDP_EXPORTS) # Include files if(NOT IOS) @@ -793,7 +787,7 @@ endif() include(CTest) if(BUILD_TESTING) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFREERDP_TEST_EXPORTS") + add_definitions(-DFREERDP_TEST_EXPORTS -DBUILD_TESTING) enable_testing()