Fix CMake build on Unix:

* CMakeLists.txt:
   - Default string options to empty string instead of boolean "OFF".
   - Expose APR/-Util libraries as interface requirements of the
     shared Serf library, since its users will have to use APR functions.

* build/APRCommon.cmake, build/FindAPR.cmake, build/FindAPRUtil.cmake:
   Fix argument and result quoting when invoking apr-1-config etc.
* build/SerfVersion.cmake: Look for serf.h header in the known source directory.


git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1835134 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb45435..3ca7011 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,15 +46,15 @@
 option(DEBUG "Enable debugging info and strict compile warnings" OFF)
 option(SKIP_SHARED "Disable building shared Serf libraries" OFF)
 option(SKIP_STATIC "Disable building static Serf libraries" OFF)
-option(LIBDIR "Indstall directory for architecture-dependent libraries" OFF)
-option(APR "Path to APR's install area" OFF)
-option(APU "Path to APR-Util's install area" OFF)
-option(OPENSSL "Path to OpenSSL's install area" OFF)
-option(ZLIB "Path to zlib's install area" OFF)
-option(GSSAPI "Path to GSSAPI's install area" OFF)
-option(BROTLI "Path to Brotli's install area" OFF)
+option(LIBDIR "Indstall directory for architecture-dependent libraries" "")
+option(APR "Path to APR's install area" "")
+option(APU "Path to APR-Util's install area" "")
+option(OPENSSL "Path to OpenSSL's install area" "")
+option(ZLIB "Path to zlib's install area" "")
+option(GSSAPI "Path to GSSAPI's install area" "")
+option(BROTLI "Path to Brotli's install area" "")
 option(APR_STATIC "Windows: Link with static APR/-Util libraries" OFF)
-option(EXPAT "Windows: optional path to Expat's install area for APR_STATIC" OFF)
+option(EXPAT "Windows: optional path to Expat's install area for APR_STATIC" "")
 option(DISABLE_LOGGING "Disable the logging framework at compile time" OFF)
 option(SKIP_TESTS "Disable building the unit tests and utilities" OFF)
 option(ENABLE_SLOW_TESTS "Enable long-running unit tests" OFF)
@@ -220,13 +220,17 @@
 set(SERF_DEPENDENCY_LIBRARIES
     ${OPENSSL_LIBRARIES}
     ${ZLIB_LIBRARIES}
+    ${SERF_STANDARD_LIBRARIES}
+)
+list(REMOVE_DUPLICATES SERF_DEPENDENCY_LIBRARIES)
+
+set(SERF_INTERFACE_LIBRARIES
     ${APR_LIBRARIES}
     ${APR_EXTRALIBS}
     ${APRUTIL_LIBRARIES}
     ${APRUTIL_EXTRALIBS}
-    ${SERF_STANDARD_LIBRARIES}
 )
-list(REMOVE_DUPLICATES SERF_DEPENDENCY_LIBRARIES)
+list(REMOVE_DUPLICATES SERF_INTERFACE_LIBRARIES)
 
 
 # Feature tests
@@ -311,7 +315,9 @@
                              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})
+  target_link_libraries(serf_shared
+                        PRIVATE ${SERF_DEPENDENCY_LIBRARIES}
+                        PUBLIC ${SERF_INTERFACE_LIBRARIES})
   set_target_properties(serf_shared
                         PROPERTIES
                         VERSION ${SERF_VERSION}
@@ -330,7 +336,9 @@
                              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})
+  target_link_libraries(serf_static
+                        INTERFACE ${SERF_DEPENDENCY_LIBRARIES}
+                                  ${SERF_INTERFACE_LIBRARIES})
   list(APPEND SERF_TARGETS "serf_static")
 endif()
 
diff --git a/build/APRCommon.cmake b/build/APRCommon.cmake
index 4dd7fc1..4a207f8 100644
--- a/build/APRCommon.cmake
+++ b/build/APRCommon.cmake
@@ -17,7 +17,7 @@
 #   under the License.
 # ===================================================================
 
-function(_apru_config _program _varname _separate _regexp)
+function(_apru_config _program _varname _regexp)
   execute_process(COMMAND ${_program} ${ARGN}
                   OUTPUT_VARIABLE _apru_output
                   RESULT_VARIABLE _apru_failed)
@@ -38,12 +38,8 @@
     string(REGEX REPLACE "^ +"          ""  _apru_output "${_apru_output}")
     string(REGEX REPLACE " +$"          ""  _apru_output "${_apru_output}")
 
-    # Optionally split the result into an argument list
-    if(${_separate})
-      separate_arguments(_apru_output)
-    endif()
-
-    set(${_varname} "${_apru_output}" PARENT_SCOPE)
+    separate_arguments(_apru_output)
+    set(${_varname} ${_apru_output} PARENT_SCOPE)
   endif()
 endfunction(_apru_config)
 
diff --git a/build/FindAPR.cmake b/build/FindAPR.cmake
index 66e513c..4c10628 100644
--- a/build/FindAPR.cmake
+++ b/build/FindAPR.cmake
@@ -67,15 +67,15 @@
   endif()
   mark_as_advanced(APR_CONFIG_EXECUTABLE)
 
-  macro(_apr_invoke _varname _separate _regexp)
-    _apru_config("${APR_CONFIG_EXECUTABLE}" "${_varname}" "${_separate}" "${_regexp}" ${ARGN})
+  macro(_apr_invoke _varname _regexp)
+    _apru_config(${APR_CONFIG_EXECUTABLE} ${_varname} "${_regexp}" "${ARGN}")
   endmacro(_apr_invoke)
 
-  _apr_invoke(APR_CFLAGS    FALSE "(^| )-(g|O)[^ ]*" --cppflags --cflags)
-  _apr_invoke(APR_INCLUDES  TRUE  "(^| )-I"          --includes)
-  _apr_invoke(APR_LIBRARIES TRUE  ""                 --link-ld)
-  _apr_invoke(APR_EXTRALIBS TRUE  ""                 --libs)
-  _apr_invoke(APR_VERSION   TRUE  ""                 --version)
+  _apr_invoke(APR_CFLAGS     "(^| )-(g|O)[^ ]*" --cppflags --cflags)
+  _apr_invoke(APR_INCLUDES   "(^| )-I"          --includes)
+  _apr_invoke(APR_LIBRARIES  ""                 --link-ld)
+  _apr_invoke(APR_EXTRALIBS  ""                 --libs)
+  _apr_invoke(APR_VERSION    ""                 --version)
   string(REGEX REPLACE "^([0-9]+)\\..*$" "\\1" _apr_major "${APR_VERSION}")
 
 endif()   # NOT Windows
diff --git a/build/FindAPRUtil.cmake b/build/FindAPRUtil.cmake
index 2be1a39..946ceb2 100644
--- a/build/FindAPRUtil.cmake
+++ b/build/FindAPRUtil.cmake
@@ -64,7 +64,7 @@
 
     _apru_version(APRUTIL_VERSION _apu_major _apu_minor "${APRUTIL_INCLUDES}/apu_version.h" "APU")
     set(_apu_name "aprutil-${_apu_major}")
-    
+
     if(${_apu_major} GREATER 1 OR (${_apu_major} EQUAL 1 AND ${_apu_minor} GREATER 5))
       set(_apu_expat_name "expat.lib")
     else()
@@ -102,15 +102,15 @@
     endif()
     mark_as_advanced(APRUTIL_CONFIG_EXECUTABLE)
 
-    macro(_apu_invoke _varname _separate _regexp)
-      _apru_config("${APRUTIL_CONFIG_EXECUTABLE}" "${_varname}" "${_separate}" "${_regexp}" ${ARGN})
+    macro(_apu_invoke _varname _regexp)
+      _apru_config(${APRUTIL_CONFIG_EXECUTABLE} ${_varname} "${_regexp}" "${ARGN}")
     endmacro(_apu_invoke)
 
-    _apu_invoke(APRUTIL_INCLUDES  TRUE  "(^| )-I" --includes)
-    _apu_invoke(APRUTIL_EXTRALIBS TRUE  ""        --libs)
-    _apu_invoke(APRUTIL_LIBRARIES TRUE  ""        --link-ld)
-    _apu_invoke(APRUTIL_LDFLAGS   FALSE ""        --ldflags)
-    _apu_invoke(APRUTIL_VERSION   TRUE  ""        --version)
+    _apu_invoke(APRUTIL_INCLUDES  "(^| )-I" --includes)
+    _apu_invoke(APRUTIL_EXTRALIBS ""        --libs)
+    _apu_invoke(APRUTIL_LIBRARIES ""        --link-ld)
+    _apu_invoke(APRUTIL_LDFLAGS   ""        --ldflags)
+    _apu_invoke(APRUTIL_VERSION   ""        --version)
 
   endif()   # NOT Windows
 
diff --git a/build/SerfVersion.cmake b/build/SerfVersion.cmake
index c5d56a6..d06ab55 100644
--- a/build/SerfVersion.cmake
+++ b/build/SerfVersion.cmake
@@ -19,7 +19,7 @@
 
 # Find the version number in serf.h so that we don't keep it in two places.
 
-set(SERF_HEADER "${CMAKE_SOURCE_DIR}/serf.h")
+set(SERF_HEADER "${SERF_SOURCE_DIR}/serf.h")
 
 unset(SERF_VERSION)
 unset(SERF_SOVERSION)