serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1835104 - in /serf/trunk: CMakeLists.txt test/CMakeLists.txt
Date Thu, 05 Jul 2018 08:11:33 GMT
Author: brane
Date: Thu Jul  5 08:11:32 2018
New Revision: 1835104

URL: http://svn.apache.org/viewvc?rev=1835104&view=rev
Log:
In CMake, add interface properties to the targets so that upstream users
can guess the needed include dirs and link libraries from target properties.

* CMakeLists.txt:
  Do not set global include_directories and APR_CFLAGS.
  (SERF_DEPENDENCY_INCLUDES): Renamed from DEPENDENCY_INCLUDES.
  (SERF_INTERFACE_INCLUDES): Split from SERF_DEPENDENCY_INCLUDES.
  (SERF_DEPENDENCY_LIBRARIES: Renamed from DEPENDENCY_LIBRARIES.
  (serf_shared): Target renamed from 'serf'.
  (serf_shared, serf_static): Set public, interface and private include
   directories and link libraries.

* test/CMakeLists.txt
  (${SIMPLE_TEST_TARGETS}): Ignore dependency libraries, depend on the
   serf_static target properties instead.
  (test_all): Likewise; also, use private properties for OpenSSL, etc.
   include directories and the MOCKHTTP_OPENSSL definition.

Modified:
    serf/trunk/CMakeLists.txt
    serf/trunk/test/CMakeLists.txt

Modified: serf/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/serf/trunk/CMakeLists.txt?rev=1835104&r1=1835103&r2=1835104&view=diff
==============================================================================
--- serf/trunk/CMakeLists.txt (original)
+++ serf/trunk/CMakeLists.txt Thu Jul  5 08:11:32 2018
@@ -199,15 +199,19 @@ if(SERF_WINDOWS)
 endif()
 
 
-set(DEPENDENCY_INCLUDES
+set(SERF_DEPENDENCY_INCLUDES
     ${OPENSSL_INCLUDE_DIR}
     ${ZLIB_INCLUDE_DIRS}
+)
+list(REMOVE_DUPLICATES SERF_DEPENDENCY_INCLUDES)
+
+set(SERF_INTERFACE_INCLUDES
     ${APR_INCLUDES}
     ${APRUTIL_INCLUDES}
 )
-list(REMOVE_DUPLICATES DEPENDENCY_INCLUDES)
+list(REMOVE_DUPLICATES SERF_INTERFACE_INCLUDES)
 
-set(DEPENDENCY_LIBRARIES
+set(SERF_DEPENDENCY_LIBRARIES
     ${OPENSSL_LIBRARIES}
     ${ZLIB_LIBRARIES}
     ${APR_LIBRARIES}
@@ -216,12 +220,7 @@ set(DEPENDENCY_LIBRARIES
     ${APRUTIL_EXTRALIBS}
     ${SERF_STANDARD_LIBRARIES}
 )
-list(REMOVE_DUPLICATES DEPENDENCY_LIBRARIES)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${APR_CFLAGS}")
-
-include_directories(BEFORE SYSTEM ${DEPENDENCY_INCLUDES})
-include_directories(${SERF_SOURCE_DIR})
+list(REMOVE_DUPLICATES SERF_DEPENDENCY_LIBRARIES)
 
 
 # Feature tests
@@ -299,30 +298,43 @@ endif(NOT MSVC)
 
 
 # Define all targets
-add_library(serf SHARED ${SOURCES} ${SHARED_SOURCES})
-target_link_libraries(serf ${DEPENDENCY_LIBRARIES})
+add_library(serf_shared SHARED ${SOURCES} ${SHARED_SOURCES})
+target_compile_options(serf_shared PUBLIC ${APR_CFLAGS})
+target_include_directories(serf_shared SYSTEM BEFORE
+                           PRIVATE ${SERF_DEPENDENCY_INCLUDES}
+                           PUBLIC ${SERF_INTERFACE_INCLUDES})
+target_include_directories(serf_shared PUBLIC ${SERF_SOURCE_DIR})
+target_link_libraries(serf_shared PRIVATE ${SERF_DEPENDENCY_LIBRARIES})
+set_target_properties(serf_shared
+                      PROPERTIES
+                      VERSION ${SERF_VERSION}
+                      SOVERSION ${SERF_SOVERSION})
 
 add_library(serf_static STATIC ${SOURCES})
+target_compile_options(serf_static PUBLIC ${APR_CFLAGS})
+target_include_directories(serf_static SYSTEM BEFORE
+                           PRIVATE ${SERF_DEPENDENCY_INCLUDES}
+                           PUBLIC ${SERF_INTERFACE_INCLUDES})
+target_include_directories(serf_static PUBLIC ${SERF_SOURCE_DIR})
+target_link_libraries(serf_static INTERFACE ${SERF_DEPENDENCY_LIBRARIES})
 
-set_target_properties(serf serf_static
+set_target_properties(serf_shared serf_static
                       PROPERTIES
-                      OUTPUT_NAME "serf-${SERF_MAJOR_VERSION}"
-                      VERSION ${SERF_VERSION}
-                      SOVERSION ${SERF_SOVERSION})
+                      OUTPUT_NAME "serf-${SERF_MAJOR_VERSION}")
 
-install(TARGETS serf serf_static
+install(TARGETS serf_shared serf_static
         ARCHIVE DESTINATION "lib"
         LIBRARY DESTINATION "lib"
         RUNTIME DESTINATION "bin")
 
 if(SERF_WINDOWS)
-  install(FILES $<TARGET_PDB_FILE:serf> DESTINATION "bin")
+  install(FILES $<TARGET_PDB_FILE:serf_shared> DESTINATION "bin")
 endif()
 
 if(NOT SERF_WINDOWS)
-  set(SERF_INCLUDE_SUBDIR "serf-${SERF_MAJOR_VERSION}")
+  set(SERF_INCLUDE_SUBDIR "/serf-${SERF_MAJOR_VERSION}")
 endif()
-install(FILES ${HEADERS} DESTINATION "include/${SERF_INCLUDE_SUBDIR}")
+install(FILES ${HEADERS} DESTINATION "include${SERF_INCLUDE_SUBDIR}")
 
 
 # Generate the pkg-config module file.

Modified: serf/trunk/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/serf/trunk/test/CMakeLists.txt?rev=1835104&r1=1835103&r2=1835104&view=diff
==============================================================================
--- serf/trunk/test/CMakeLists.txt (original)
+++ serf/trunk/test/CMakeLists.txt Thu Jul  5 08:11:32 2018
@@ -48,17 +48,17 @@ if(CC_LIKE_GNUC)
   string(REPLACE "-std=c89" "-std=c99" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
 endif()
 
-add_definitions("-DMOCKHTTP_OPENSSL")
-
 foreach(TEST_TARGET ${SIMPLE_TEST_TARGETS})
   add_executable(${TEST_TARGET} "${TEST_TARGET}.c")
   add_dependencies(${TEST_TARGET} serf_static)
-  target_link_libraries(${TEST_TARGET} serf_static ${DEPENDENCY_LIBRARIES})
+  target_link_libraries(${TEST_TARGET} serf_static)
 endforeach()
 
 add_executable(test_all ${TEST_ALL_SOURCES})
 add_dependencies(test_all serf_static)
-target_link_libraries(test_all serf_static ${DEPENDENCY_LIBRARIES})
+target_compile_definitions(test_all PRIVATE "-DMOCKHTTP_OPENSSL")
+target_include_directories(test_all SYSTEM BEFORE PRIVATE ${SERF_DEPENDENCY_INCLUDES})
+target_link_libraries(test_all serf_static)
 
 file(GLOB RESPONSE_TEST_CASES "${CMAKE_CURRENT_SOURCE_DIR}/testcases/*.response")
 foreach(TEST_CASE ${RESPONSE_TEST_CASES})



Mime
View raw message