Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Windows system include headers #150

Open
Pwera opened this issue Feb 12, 2018 · 0 comments
Open

Problem with Windows system include headers #150

Pwera opened this issue Feb 12, 2018 · 0 comments

Comments

@Pwera
Copy link

Pwera commented Feb 12, 2018

Hello, i'm moving ActiveMQ-cpp library into CMake, without PCH library builds fine, but if i enable Cotire it adds into Decaf_CXX_prefix.h headers like Windows.h, WinSock2.h, WS2tcpip.h and compiler throw errors like (redefinitions):

 C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ws2def.h(217): error C2011:
 C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ws2def.h(414): error C2059:
 C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ws2def.h(414): error C3805:
 C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ws2def.h(608): error C2011:
 C:\Program Files (x86)\Windows Kits\8.1\Include\um\WinSock2.h(125): error C2011: 
 C:\Program Files (x86)\Windows Kits\8.1\Include\um\WinSock2.h(169): error C2011: 

project CMakeLists.txt

cmake_minimum_required(VERSION 3.10)
project(ActiveMqTraining C CXX)
SET(CMAKE_CXX_STANDARD 11)

option(BUILD_EXAMPLES "Build Example applications" FALSE)
option(BUILD_TESTS "Build Test applications" FALSE)
option(CMAKE_VERBOSE_MAKEFILE "Use verbose output" TRUE)

set(COTERIZE_BUILD TRUE)
set(COTIRE_DEBUG TRUE)
set(COTIRE_VERBOSE TRUE)
set(COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES 1)
if(DEFINED COTERIZE_BUILD)
    include(cotire)
endif()

find_package(APR 1.0.0 REQUIRED)
find_package(Threads REQUIRED)

file(GLOB_RECURSE SOURCES ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemqES
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/io/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/net/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/nio/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/security/provider/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/security/windows/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/security/Engine.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cp-cpp/src/main/decaf/internal/util/concurrent/ExecutorsSupport.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/concurrent/ThreadLocalImpl.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/zip/*.c
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/GenericResource.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/HexStringParser.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/Resource.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/ResourceLifecycleManager.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/AprPool.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/io/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/lang/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/net/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/nio/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/security/*.cpp
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/decaf/util/*.cpp
        )

file(GLOB_RECURSE ActiveMq_SOURCES
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/activemq/*.cpp
        )
file(GLOB_RECURSE Cms_SOURCES
        ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main/cms/*.cpp
        )

######################  LIBRARY SECTION  ###################################

set(DECAF_UTIL_PATH ${CMAKE_SOURCE_DIR}/external/activemq-cpp/activemq-cpp/src/main)
add_library(Decaf STATIC ${SOURCES} ${ActiveMq_SOURCES} ${Cms_SOURCES})
target_include_directories(Decaf
        PUBLIC
        $<BUILD_INTERFACE:${DECAF_UTIL_PATH}>)

if(MSVC)
    target_compile_options(Decaf PUBLIC /wd4101 /wd4005)
endif()

target_link_libraries(Decaf PUBLIC APR::libapr-2)
if(DEFINED COTERIZE_BUILD)
    set_target_properties(Decaf PROPERTIES
            COTIRE_ADD_UNITY_BUILD FALSE) "${APR_INCLUDE_DIR}")

            cotire(Decaf)

endif()

######################  EXAMPLES SECTION  ###################################

if (BUILD_EXAMPLES)
    function(ActiveMqSample name sourceList)
        add_executable(${name} ${sourceList})
        target_link_libraries(${name} PUBLIC ${APR_LIBRARIES} Decaf)
        target_include_directories(${name}
                PRIVATE
                $<BUILD_INTERFACE:${DECAF_UTIL_PATH}>
                $<BUILD_INTERFACE:${APR_INCLUDE_DIR}>)

    endfunction(ActiveMqSample)
ActiveMqSample(AdvisoryConsumer "${DECAF_UTIL_PATH}/../examples/advisories/AdvisoryConsumer.cpp;${DECAF_UTIL_PATH}/../examples/advisories/AdvisoryConsumerMain.cpp")
ActiveMqSample(AdvisoryProducer "${DECAF_UTIL_PATH}/../examples/advisories/AdvisoryProducer.cpp;${DECAF_UTIL_PATH}/../examples/advisories/AdvisoryProducerMain.cpp")
ActiveMqSample(TempDestinationAdvisoryProducer "${DECAF_UTIL_PATH}/../examples/advisories/TempDestinationAdvisoryProducerMain.cpp")
ActiveMqSample(TempDestinationAdvisoryConsumer "${DECAF_UTIL_PATH}/../examples/advisories/TempDestinationAdvisoryConsumer.cpp;${DECAF_UTIL_PATH}/../examples/advisories/TempDestinationAdvisoryConsumerMain.cpp")
ActiveMqSample(CmsTemplateReceiver "${DECAF_UTIL_PATH}/../examples/cmstemplate/CMSTemplateReceiver.cpp")
ActiveMqSample(CmsTemplateSender "${DECAF_UTIL_PATH}/../examples/cmstemplate/CMSTemplateSender.cpp")
endif ()

Decaf_CXX_prefix.h
Cotire will generate

/* cotire.cmake 1.7.10 generated file */
/* D:/libs/ActiveMqCppTraining/msvcV3/Debug/cotire/Decaf_CXX_prefix.hxx */
#pragma warning(push, 0)
#ifdef __cplusplus
#include "C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stddef.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\Windows.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\WinSock2.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\WS2tcpip.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\MSWSock.h"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\string"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\vector"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\iostream"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\sstream"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\algorithm"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\memory"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\functional"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\map"
#include "C:\lib2\msvc\include\apr_pools.h"
#include "C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\process.h"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\list"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\set"
#include "C:\lib2\msvc\include\apr_signal.h"
#include "C:\lib2\msvc\include\apr_portable.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\wincrypt.h"
#include "C:\lib2\msvc\include\apr_strings.h"
#include "C:\lib2\msvc\include\apr_env.h"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\deque"
#include "C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\assert.h"
#include "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\iomanip"
#endif
#pragma warning(pop)

When i explicit remove headers:

#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\Windows.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\WinSock2.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\WS2tcpip.h"
#include "C:\Program Files (x86)\Windows Kits\8.1\Include\um\MSWSock.h"

build go fine again.
This headers comes from apr.
How to debug/fix this?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant