Changeset: dc333e9166fc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dc333e9166fc
Added Files:
        cmake/FindIconvMonetDB.cmake
Modified Files:
        CMakeLists.txt
        clients/odbc/winsetup/setup.c
        cmake/FindNetCDF.cmake
        common/stream/CMakeLists.txt
        gdk/CMakeLists.txt
        gdk/gdk_posix.c
        gdk/monetdb-gdk.pc.in
        monetdb5/tools/CMakeLists.txt
Branch: cmake-fun
Log Message:

Test for libiconv_open symbol on FreeBSD, because it requires it. Also fixed 
some pkg-config libraries output.

Don't include windows.h more than once.


diffs (205 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -321,15 +321,12 @@ if(NOT BISON_FOUND)
 endif()
 
 # Iconv
-set(ICONV_INCLUDE_DIR "")
-set(ICONV_LIBRARIES "")
-include(FindIconv)
-if(Iconv_FOUND)
+include(FindIconvMonetDB)
+if(ICONV_FOUND)
        set(HAVE_ICONV ON)
-       if(NOT Iconv_IS_BUILT_IN)
-               set(ICONV_INCLUDE_DIR "${Iconv_INCLUDE_DIR}")
-               set(ICONV_LIBRARIES "${Iconv_LIBRARY}")
-       endif()
+else()
+       set(ICONV_INCLUDE_DIR "")
+       set(ICONV_LIBRARIES "")
 endif()
 
 set(WITH_BZ2 "AUTO" CACHE STRING "Include bz2 support (default=AUTO)") # Check 
with BZip2_FOUND
@@ -429,7 +426,7 @@ set(THREAD_LIBRARIES "${CMAKE_THREAD_LIB
 
 # Readline libraries
 set(READLINE_LIBRARIES "")
-set(WITH_READLINE "AUTO" CACHE PATH "Include readline support (default=AUTO)") 
# Check with HAVE_LIBREADLINE
+set(WITH_READLINE "AUTO" CACHE STRING "Include readline support 
(default=AUTO)") # Check with HAVE_LIBREADLINE
 if(NOT ${WITH_READLINE} STREQUAL "NO")
        cmake_push_check_state()
        set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};readline")
@@ -821,7 +818,7 @@ if(NOT PROJ_FOUND)
 endif()
 
 set(SAMTOOLS_LIBRARIES "")
-set(ENABLE_SAMTOOLS "AUTO" CACHE PATH "Include Samtools support 
(default=AUTO)") # Check with HAVE_SAMTOOLS
+set(ENABLE_SAMTOOLS "AUTO" CACHE STRING "Include Samtools support 
(default=AUTO)") # Check with HAVE_SAMTOOLS
 if(NOT ${ENABLE_SAMTOOLS} STREQUAL "NO")
        cmake_push_check_state()
        set(CMAKE_REQUIRED_LIBRARIES 
"${CMAKE_REQUIRED_LIBRARIES};${MATH_LIBRARIES};${THREAD_LIBRARIES};${ZLIB_LIBRARIES};bam")
diff --git a/clients/odbc/winsetup/setup.c b/clients/odbc/winsetup/setup.c
--- a/clients/odbc/winsetup/setup.c
+++ b/clients/odbc/winsetup/setup.c
@@ -7,7 +7,6 @@
  */
 
 #include "monetdb_config.h"
-#include <windows.h>
 /* indicate to sqltypes.h that windows.h has already been included and
    that it doesn't have to define Windows constants */
 #ifndef ALREADY_HAVE_WINDOWS_TYPE
diff --git a/cmake/FindIconvMonetDB.cmake b/cmake/FindIconvMonetDB.cmake
new file mode 100644
--- /dev/null
+++ b/cmake/FindIconvMonetDB.cmake
@@ -0,0 +1,37 @@
+# - Find iconv
+# Test if iconv is natively supported or not
+# WARNING This file name is FindIconvMonetDB to not confuse with FindIconv 
from Cmake. We don't use that version because
+# we have to check for existence of libiconv_open symbol in FreeBSD.
+#
+# ICONV_INCLUDE_DIR    - where to find iconv.h, etc.
+# ICONV_LIBRARIES      - List of libraries when using iconv.
+# ICONV_FOUND  - True if iconv found.
+# ICONV_IS_BUILT_IN - If iconv is built in
+
+if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") # On FreeBSD, libiconv_open symbol 
is required
+       check_symbol_exists("libiconv_open" "iconv.h" ICONV_IS_BUILT_IN)
+else()
+       check_symbol_exists("iconv_open" "iconv.h" ICONV_IS_BUILT_IN)
+endif()
+
+if(ICONV_IS_BUILT_IN)
+       set(ICONV_INCLUDE_DIR "")
+       set(ICONV_LIBRARY_NAME "c")
+else()
+       # Look for the header file
+       find_path(ICONV_INCLUDE_DIR NAMES "iconv.h" DOC "iconv include 
directory")
+       # Search if the library name is iconv or libiconv
+       find_path(ICONV_LIBRARY_NAME NAMES "iconv" "libiconv" DOC "iconv 
library")
+endif()
+
+# Look for the library
+find_library(ICONV_LIBRARIES NAMES "${ICONV_LIBRARY_NAME}" DOC "iconv library 
(potentially the C library)")
+
+include(FindPackageHandleStandardArgs)
+if(ICONV_IS_BUILT_IN) # If the library is built in, we don't have to check if 
the include directory is ok, because it will be empty
+       find_package_handle_standard_args(Iconv REQUIRED_VARS ICONV_LIBRARIES)
+else()
+       find_package_handle_standard_args(Iconv REQUIRED_VARS ICONV_LIBRARIES 
ICONV_INCLUDE_DIR)
+endif()
+
+mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARIES)
diff --git a/cmake/FindNetCDF.cmake b/cmake/FindNetCDF.cmake
--- a/cmake/FindNetCDF.cmake
+++ b/cmake/FindNetCDF.cmake
@@ -1,7 +1,7 @@
 # - Find netcdf
 # Find the native netcdf headers and libraries.
 #
-# NETCDF_INCLUDE_DIR   - where to find proj_api.h, etc.
+# NETCDF_INCLUDE_DIR   - where to find netcdf.h, etc.
 # NETCDF_LIBRARIES     - List of libraries when using netcdf.
 # NETCDF_VERSION       - netcdf version if found
 # NETCDF_FOUND - True if netcdf found.
diff --git a/common/stream/CMakeLists.txt b/common/stream/CMakeLists.txt
--- a/common/stream/CMakeLists.txt
+++ b/common/stream/CMakeLists.txt
@@ -27,25 +27,26 @@ if(WIN32)
        install(FILES $<TARGET_PDB_FILE:stream> DESTINATION ${LIBDIR} OPTIONAL)
 else()
        if(CURL_FOUND)
-               set(PKG_CURL "-lcurl")
+               set(PKG_CURL "${CMAKE_SHARED_LIBRARY_PREFIX}curl")
        endif()
        if(ZLIB_FOUND)
-               set(PKG_ZLIB "-lz")
+               set(PKG_ZLIB "zlib")
        endif()
        if(LIBLZMA_FOUND)
-               set(PKG_LIBLZMA "-llzma")
+               set(PKG_LIBLZMA "${CMAKE_SHARED_LIBRARY_PREFIX}lzma")
        endif()
        if(LZ4_FOUND)
-               set(PKG_LZ4 "-llz4")
+               set(PKG_LZ4 "${CMAKE_SHARED_LIBRARY_PREFIX}lz4")
        endif()
        if(BZIP2_FOUND)
-               set(PKG_BZIP2 "-lbz2")
+               set(PKG_BZIP2 "bzip2")
        endif()
        if(SNAPPY_FOUND)
-               set(PKG_SNAPPY "-lsnappy")
+               set(PKG_SNAPPY "snappy")
        endif()
-       if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN)
-               set(PKG_LIBICONV "-l${ICONV_LIBRARIES}") # TODO this one is 
broken in some platforms
+       if(ICONV_FOUND AND NOT ICONV_IS_BUILT_IN)
+               get_filename_component(ICONV_LIBRARIES_PATH 
"${ICONV_LIBRARIES}" DIRECTORY)
+               set(PKG_LIBICONV "-L${ICONV_LIBRARIES_PATH} 
-l${ICONV_LIBRARIES}")
        endif()
        configure_file(monetdb-stream.pc.in 
${CMAKE_CURRENT_BINARY_DIR}/monetdb-stream.pc @ONLY)
        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/monetdb-stream.pc DESTINATION 
${PKGCONFIGDIR})
diff --git a/gdk/CMakeLists.txt b/gdk/CMakeLists.txt
--- a/gdk/CMakeLists.txt
+++ b/gdk/CMakeLists.txt
@@ -64,7 +64,7 @@ else()
                set(PKG_MATH "-l${MATH_LIBRARIES}")
        endif()
        if(NOT "${THREAD_LIBRARIES}" STREQUAL "")
-               set(PKG_THREAD "${THREAD_LIBRARIES}") # TODO this one is broken 
on some platforms
+               set(PKG_THREAD "${THREAD_LIBRARIES}")
        endif()
        if(NOT "${DL_LIBRARIES}" STREQUAL "")
                set(PKG_DL "-l${DL_LIBRARIES}")
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -672,11 +672,9 @@ mdlopen(const char *library, int mode)
 #undef rmdir
 #undef mkdir
 
-#include <windows.h>
-
-#ifdef _MSC_VER
+#ifdef HAVE_IO_H
 #include <io.h>
-#endif /* _MSC_VER */
+#endif
 #include <Psapi.h>
 
 #define MT_SMALLBLOCK 256
diff --git a/gdk/monetdb-gdk.pc.in b/gdk/monetdb-gdk.pc.in
--- a/gdk/monetdb-gdk.pc.in
+++ b/gdk/monetdb-gdk.pc.in
@@ -14,5 +14,5 @@ Description: MonetDB GDK libary
 Version: @PACKAGE_VERSION@
 Requires: monetdb-stream
 
-Libs: -L${libdir} -lbat @PKG_MATH@ @PKG_THREAD@ @PKG_DL@  @PKG_KVM@
+Libs: -L${libdir} -lbat @PKG_MATH@ @PKG_THREAD@ @PKG_DL@ @PKG_KVM@
 Cflags: -I${includedir}/monetdb
diff --git a/monetdb5/tools/CMakeLists.txt b/monetdb5/tools/CMakeLists.txt
--- a/monetdb5/tools/CMakeLists.txt
+++ b/monetdb5/tools/CMakeLists.txt
@@ -27,11 +27,14 @@ else()
        if(LIBXML2_FOUND)
                set(PKG_LIBXML2 "libxml-2.0")
        endif()
-       if(COMMONCRYPTO_FOUND OR OPENSSL_FOUND)
-               set(PKG_CRYPTO "-lcrypto") # In OpenSSL case, we link only to 
the crypto library, so it will be always one library to link to
+       if(OPENSSL_FOUND)
+               # In OpenSSL case, we link only to the crypto library, so it 
will be always one library to link to
+               get_filename_component(CRYPTO_LIBRARIES_PATH 
"${CRYPTO_LIBRARIES}" DIRECTORY)
+               set(PKG_CRYPTO "-L${CRYPTO_LIBRARIES_PATH} -lcrypto")
        endif()
        if(HAVE_LIBPCRE)
-               set(PKG_PCRE "-lpcre")
+               get_filename_component(PCRE_LIBRARIES_PATH "${PCRE_LIBRARIES}" 
DIRECTORY)
+               set(PKG_PCRE "-L${PCRE_LIBRARIES_PATH} -lpcre")
        endif()
        configure_file(monetdb5.pc.in ${CMAKE_CURRENT_BINARY_DIR}/monetdb5.pc 
@ONLY)
        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/monetdb5.pc DESTINATION 
${PKGCONFIGDIR})
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to