From b4a534a23568e97be58fe64ed97dd9e694af4321 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 24 Sep 2013 20:17:39 +0400 Subject: [PATCH] cmake: PCH: use DEFINE_SYMBOL target property --- cmake/OpenCVPCHSupport.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake index 9b849ebd79..328386a4dd 100644 --- a/cmake/OpenCVPCHSupport.cmake +++ b/cmake/OpenCVPCHSupport.cmake @@ -25,11 +25,13 @@ IF(CMAKE_COMPILER_IS_GNUCXX) SET(_PCH_include_prefix "-I") SET(_PCH_isystem_prefix "-isystem") + SET(_PCH_define_prefix "-D") ELSEIF(CMAKE_GENERATOR MATCHES "^Visual.*$") SET(PCHSupport_FOUND TRUE) SET(_PCH_include_prefix "/I") SET(_PCH_isystem_prefix "/I") + SET(_PCH_define_prefix "/D") ELSE() SET(PCHSupport_FOUND FALSE) ENDIF() @@ -237,6 +239,14 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input) _PCH_GET_COMPILE_FLAGS(_compile_FLAGS) + get_target_property(type ${_targetName} TYPE) + if(type STREQUAL "SHARED_LIBRARY") + get_target_property(__DEFINES ${_targetName} DEFINE_SYMBOL) + if(NOT __DEFINES MATCHES __DEFINES-NOTFOUND) + list(APPEND _compile_FLAGS "${_PCH_define_prefix}${__DEFINES}") + endif() + endif() + #MESSAGE("_compile_FLAGS: ${_compile_FLAGS}") #message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")