Skip to content

Commit

Permalink
Update interface compile definitions for Windows using CMake (conflue…
Browse files Browse the repository at this point in the history
…ntinc#1800, @raulbocanegra)

* Add new preprocessor flag to avoid redefining macros defined by cmake

* Transform from CMake options to C preprocessor flags

* Add rddl.c on windows to avoid linker failures due to undefined rd_dl_open

* New CMake option to avoid win32 hand crafted config

* Add sources to rdkafka_cpp on Windows to make it compile.

* Add crypt32 static link dependency as stated on openssl notes on building under Windows.
"If you link with static OpenSSL libraries then you're expected to
 additionally link your application with WS2_32.LIB, GDI32.LIB,
 ADVAPI32.LIB, CRYPT32.LIB and USER32.LIB."
This maybe a feature request for CMake's FindOpenSSL.cmake module on Windows

* Make examples compile on Windows with CMake

* Make test compile on Windows with CMake

* Add export macros for shared builds on cmake

* Merge branch 'master' of https://github.com/edenhill/librdkafka

# Conflicts:
#	src/CMakeLists.txt

* Add LIBRDKAFKACPP_EXPORTS=0 to INTERFACE compile definitions of rdkafka++

* Remove useless compile definitions

* rebase of changes

* Add LIBRDKAFKACPP_EXPORTS=0 to INTERFACE compile definitions of rdkafka++

* Remove useless compile definitions

* Add sources to rdkafka_cpp on Windows to make it compile.

* Add crypt32 static link dependency as stated on openssl notes on building under Windows.
"If you link with static OpenSSL libraries then you're expected to
 additionally link your application with WS2_32.LIB, GDI32.LIB,
 ADVAPI32.LIB, CRYPT32.LIB and USER32.LIB."
This maybe a feature request for CMake's FindOpenSSL.cmake module on Windows

* Add LIBRDKAFKACPP_EXPORTS=0 to INTERFACE compile definitions of rdkafka++

* Remove useless compile definitions

* rebase of changes
  • Loading branch information
raulbocanegra authored and edenhill committed Jun 7, 2018
1 parent b533e9c commit 84aa468
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 1 addition & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
if(WIN32)
set(win32_sources ../win32/wingetopt.c ../win32/wingetopt.h)
set(win32_compile_defs "LIBRDKAFKACPP_EXPORTS=0")
endif(WIN32)

add_executable(rdkafka_simple_producer rdkafka_simple_producer.c ${win32_sources})
Expand All @@ -11,11 +10,9 @@ target_link_libraries(rdkafka_performance PUBLIC rdkafka)

add_executable(rdkafka_example_cpp rdkafka_example.cpp ${win32_sources})
target_link_libraries(rdkafka_example_cpp PUBLIC rdkafka++)
target_compile_definitions(rdkafka_example_cpp PRIVATE ${win32_compile_defs})

add_executable(rdkafka_consumer_example_cpp rdkafka_consumer_example.cpp ${win32_sources})
target_link_libraries(rdkafka_consumer_example_cpp PUBLIC rdkafka++)
target_compile_definitions(rdkafka_consumer_example_cpp PRIVATE ${win32_compile_defs})

# The targets below has Unix include dirs and do not compile on Windows.
if(NOT WIN32)
Expand All @@ -27,4 +24,4 @@ if(NOT WIN32)

add_executable(kafkatest_verifiable_client kafkatest_verifiable_client.cpp)
target_link_libraries(kafkatest_verifiable_client PUBLIC rdkafka++)
endif(NOT WIN32)
endif(NOT WIN32)
3 changes: 3 additions & 0 deletions src-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ target_link_libraries(rdkafka++ PUBLIC rdkafka)
target_include_directories(rdkafka++ PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>")
if(NOT RDKAFKA_BUILD_STATIC)
target_compile_definitions(rdkafka++ PRIVATE LIBRDKAFKACPP_EXPORTS)
if(WIN32)
target_compile_definitions(rdkafka++ INTERFACE LIBRDKAFKACPP_EXPORTS=0)
endif()
endif()
install(
TARGETS rdkafka++
Expand Down
8 changes: 5 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ target_compile_definitions(rdkafka PUBLIC ${rdkafka_compile_definitions})
if(RDKAFKA_BUILD_STATIC)
target_compile_definitions(rdkafka PUBLIC LIBRDKAFKA_STATICLIB)
endif()
if(WIN32)
target_link_libraries(rdkafka PUBLIC crypt32)
if(NOT RDKAFKA_BUILD_STATIC)

if(WIN32)
if(RDKAFKA_BUILD_STATIC)
target_link_libraries(rdkafka PUBLIC crypt32)
else()
target_compile_definitions(rdkafka PRIVATE LIBRDKAFKA_EXPORTS)
endif()
endif()
Expand Down

0 comments on commit 84aa468

Please sign in to comment.