|
From: <ai...@us...> - 2014-02-05 22:23:42
|
Revision: 12975
http://sourceforge.net/p/plplot/code/12975
Author: airwin
Date: 2014-02-05 22:23:38 +0000 (Wed, 05 Feb 2014)
Log Message:
-----------
Update the configuration of pkg-config files so that good results are
obtained on MinGW/MSYS.
Lightly tested on MinGW/MSYS/Wine using the traditional build of
some of the installed examples.
Modified Paths:
--------------
trunk/cmake/modules/pkg-config.cmake
trunk/cmake/modules/plplot_functions.cmake
trunk/src/CMakeLists.txt
Modified: trunk/cmake/modules/pkg-config.cmake
===================================================================
--- trunk/cmake/modules/pkg-config.cmake 2014-02-02 19:32:14 UTC (rev 12974)
+++ trunk/cmake/modules/pkg-config.cmake 2014-02-05 22:23:38 UTC (rev 12975)
@@ -42,10 +42,17 @@
set(PKG_CONFIG_DIR "${LIB_DIR}/pkgconfig")
set(env_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH})
if(env_PKG_CONFIG_PATH)
- set(PKG_CONFIG_ENV PKG_CONFIG_PATH="${PKG_CONFIG_DIR}:${env_PKG_CONFIG_PATH}")
+ set(_pkg_config_path "${PKG_CONFIG_DIR};${env_PKG_CONFIG_PATH}")
else(env_PKG_CONFIG_PATH)
- set(PKG_CONFIG_ENV PKG_CONFIG_PATH="${PKG_CONFIG_DIR}")
+ set(_pkg_config_path "${PKG_CONFIG_DIR}")
endif(env_PKG_CONFIG_PATH)
+
+ if(MINGW)
+ determine_msys_path(_pkg_config_path "${_pkg_config_path}")
+ endif(MINGW)
+
+ set(PKG_CONFIG_ENV PKG_CONFIG_PATH="${_pkg_config_path}")
+
else(PKG_CONFIG_EXECUTABLE)
message(STATUS "Looking for pkg-config - not found")
message(STATUS
@@ -110,7 +117,8 @@
macro(pkg_config_link_flags _link_flags_out _link_flags_in)
# Transform link flags into a form that is suitable to be used for
# output pkg-config (*.pc) files.
- # N.B. ${_link_flags_in} must be a string and not a list.
+ # N.B. ${_link_flags_in} must be in quoted "${list_variable}" form
+ # where list_variable is a CMake list.
# First strip out optimized / debug options which are not needed
# Currently only FindQt4 seems to need this.
@@ -135,28 +143,42 @@
# since it appears pkg-config handles that latter form much better (with
# regard to keeping the correct order and eliminating duplicates).
- # These REGEX REPLACE's won't actually replace anything on bare windows since
- # library names are not of this form on that platform. Something to be
- # considered later if we decide to use pkg-config on bare windows.
+ # This logic appears to work fine on Linux, Mac OS X, and MinGW/MSYS
+ # but it may need some generalization on other platforms such as
+ # Cygwin.
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(suffix_list "\\.so" "\\.a")
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set(suffix_list "\\.so" "\\.a" "\\.dylib")
+ elseif(WIN32_OR_CYGWIN)
+ # Order is important here.
+ set(suffix_list "\\.dll\\.a" "\\.a")
+ else(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ # Probably a non-Linux, non-Mac OS X, Unix platform
+ # For this case we assume the same as Linux.
+ set(suffix_list "\\.so" "\\.a")
+ endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- # This logic will need to be expanded for Unix platforms other than
- # Mac OS X and Linux.
- if(APPLE)
- set(suffix_list ".so" ".a" ".dylib")
- else(APPLE)
- set(suffix_list ".so" ".a")
- endif(APPLE)
-
foreach(suffix ${suffix_list})
+ if(WIN32_OR_CYGWIN)
+ # Look for colon-delimited drive-letter form on these platforms.
+ string(
+ REGEX REPLACE "([a-zA-Z]:/[^ ]*)/lib([^ ]*)${suffix}" "-L\\1 -l\\2"
+ ${_link_flags_out}
+ "${${_link_flags_out}}"
+ )
+ #message("(${suffix}) ${_link_flags_out} = ${${_link_flags_out}}")
+ endif(WIN32_OR_CYGWIN)
+ # Look for form starting with "/" on all platforms.
string(
- REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\${suffix}" "-L\\1 -l\\2"
- ${_link_flags_out}
- "${${_link_flags_out}}"
- )
+ REGEX REPLACE "(/[^ ]*)/lib([^ ]*)${suffix}" "-L\\1 -l\\2"
+ ${_link_flags_out}
+ "${${_link_flags_out}}"
+ )
#message("(${suffix}) ${_link_flags_out} = ${${_link_flags_out}}")
endforeach(suffix ${suffix_list})
- if(APPLE)
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# For Mac OS X transform frameworks information into correct form.
string(
REGEX REPLACE
@@ -166,7 +188,7 @@
${${_link_flags_out}}
)
#message("(frameworks) ${_link_flags_out} = ${${_link_flags_out}}")
- endif(APPLE)
+ endif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endmacro(pkg_config_link_flags)
Modified: trunk/cmake/modules/plplot_functions.cmake
===================================================================
--- trunk/cmake/modules/plplot_functions.cmake 2014-02-02 19:32:14 UTC (rev 12974)
+++ trunk/cmake/modules/plplot_functions.cmake 2014-02-05 22:23:38 UTC (rev 12975)
@@ -221,3 +221,21 @@
#message("DEBUG: (filtered) ${rpath} = ${internal_rpath}")
set(${rpath} ${internal_rpath} PARENT_SCOPE)
endfunction(filter_rpath)
+
+if(MINGW)
+ # Useful function to convert Windows list of semicolon-delimited
+ # PATHs to the equivalent list of MSYS PATHs (exactly like the
+ # colon-delimited Unix list of PATHs except the driver letters are
+ # specified as the initial one-character component of each of the
+ # PATHs). For example, this function will transform the Windows
+ # list of PATHs, "z:\path1;c:\path2" to "/z/path1:/c/path2".
+ function(determine_msys_path MSYS_PATH NATIVE_PATH)
+ #message(STATUS "NATIVE_PATH = ${NATIVE_PATH}")
+ string(REGEX REPLACE "^\([a-zA-z]\):" "/\\1" PATH "${NATIVE_PATH}")
+ string(REGEX REPLACE ";\([a-zA-z]\):" ";/\\1" PATH "${PATH}")
+ string(REGEX REPLACE ";" ":" PATH "${PATH}")
+ file(TO_CMAKE_PATH "${PATH}" PATH)
+ #message(STATUS "MSYS_PATH = ${PATH}")
+ set(${MSYS_PATH} ${PATH} PARENT_SCOPE)
+ endfunction(determine_msys_path)
+endif(MINGW)
Modified: trunk/src/CMakeLists.txt
===================================================================
--- trunk/src/CMakeLists.txt 2014-02-02 19:32:14 UTC (rev 12974)
+++ trunk/src/CMakeLists.txt 2014-02-05 22:23:38 UTC (rev 12975)
@@ -191,15 +191,17 @@
set(PC_REQUIRES_TAG "Requires")
endif(NON_TRANSITIVE)
+# Deal with external libraries.
set(LIB_INSTALL_RPATH ${LIB_DIR})
+set(libplplot${LIB_TAG}_LINK_LIBRARIES)
if(ENABLE_DYNDRIVERS)
- set(libplplot${LIB_TAG}_LINK_LIBRARIES ${LTDL_LIBRARIES})
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES ${LTDL_LIBRARIES})
#message("libplplot${LIB_TAG}_LINK_LIBRARIES = ${libplplot${LIB_TAG}_LINK_LIBRARIES}")
#message("libplplot${LIB_TAG}_RPATH = ${libplplot${LIB_TAG}_RPATH}")
- set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${libplplot${LIB_TAG}_RPATH})
+ list(APPEND LIB_INSTALL_RPATH ${libplplot${LIB_TAG}_RPATH})
else(ENABLE_DYNDRIVERS)
- set(libplplot${LIB_TAG}_LINK_LIBRARIES ${DRIVERS_LINK_FLAGS})
- set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${DRIVERS_RPATH})
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES ${DRIVERS_LINK_FLAGS})
+ list(APPEND LIB_INSTALL_RPATH ${DRIVERS_RPATH})
if(ANY_QT_DEVICE)
# Update the target COMPILE_DEFINITIONS and INCLUDE_DIRECTORIES
set_qt_target_properties(plplot${LIB_TAG})
@@ -208,18 +210,47 @@
#message("DEBUG: LIB_INSTALL_RPATH = ${LIB_INSTALL_RPATH}")
if(MATH_LIB)
- set(
- libplplot${LIB_TAG}_LINK_LIBRARIES
- ${libplplot${LIB_TAG}_LINK_LIBRARIES}
- ${MATH_LIB}
- )
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES ${MATH_LIB})
endif(MATH_LIB)
# Transform "${libplplot${LIB_TAG}_LINK_LIBRARIES}" string to the
# standard pkg-config form.
+if(HAVE_SHAPELIB)
+ get_source_file_property(PLMAP_COMPILE_PROPS plmap.c COMPILE_FLAGS)
+ # Deal with NOTFOUND case.
+ if(NOT PLMAP_COMPILE_PROPS)
+ set(PLMAP_COMPILE_PROPS)
+ endif(NOT PLMAP_COMPILE_PROPS)
+ set_source_files_properties(plmap.c
+ PROPERTIES
+ COMPILE_FLAGS "${PLMAP_COMPILE_PROPS} -I${SHAPELIB_INCLUDE_DIR}"
+ )
+ if(HAVE_SAHOOKS)
+ set_source_files_properties(plmap.c
+ PROPERTIES
+ COMPILE_DEFINITIONS HAVE_SAHOOKS
+ )
+ endif(HAVE_SAHOOKS)
+
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES ${SHAPELIB_LIBRARIES})
+ list(APPEND LIB_INSTALL_RPATH ${SHAPELIB_RPATH})
+
+endif(HAVE_SHAPELIB)
+
+if(WITH_FREETYPE)
+ get_source_file_property(PLFREETYPE_COMPILE_PROPS plfreetype.c COMPILE_FLAGS)
+ # Deal with NOTFOUND case.
+ if(NOT PLFREETYPE_COMPILE_PROPS)
+ set(PLFREETYPE_COMPILE_PROPS)
+ endif(NOT PLFREETYPE_COMPILE_PROPS)
+ set_source_files_properties(plfreetype.c PROPERTIES COMPILE_FLAGS "${PLFREETYPE_COMPILE_PROPS} -I${FREETYPE_INCLUDE_DIR}")
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES ${FREETYPE_LIBRARIES})
+
+endif(WITH_FREETYPE)
+
set(libstdcxx_full_path)
-if(NOT BUILD_SHARED_LIBS)
+if(ENABLE_cxx AND NOT BUILD_SHARED_LIBS)
# For this special case where the plplot library is a static C++
# library, pkg-config needs to add -L and -l options corresponding
# to libstd++.so to the link flags it delivers. Another alternative
@@ -243,15 +274,17 @@
endif(EXISTS "${CMAKE_CXX_COMPILER}")
if(CXX_rc STREQUAL "0" AND CXX_string MATCHES "LIBRARY_PATH=")
string(REGEX REPLACE "^.*(LIBRARY_PATH=.*)\nCOLLECT_GCC_OPTIONS.*$" "\\1"
- CXX_library_path_string ${CXX_string}
+ CXX_library_path_string "${CXX_string}"
)
#message(STATUS "CXX_library_path_string = ${CXX_library_path_string}")
if(CXX_library_path_string MATCHES "^LIBRARY_PATH=")
- string(REGEX REPLACE "^LIBRARY_PATH=" "" CXX_library_path ${CXX_library_path_string})
- # This converts native path delimiters to a semicolon-delimited
- #(cmake) list of directories.
- file(TO_CMAKE_PATH ${CXX_library_path} CXX_library_path)
- message(STATUS "CXX_library_path = ${CXX_library_path}")
+ string(REGEX REPLACE "^LIBRARY_PATH=" "" CXX_library_path "${CXX_library_path_string}")
+ # For both Linux and MinGW, CXX_library_path is a semicolon
+ # delimited list which is identical to the form of a CMake list.
+ # Furthermore, for the MinGW case, the drive letters are in the
+ # colon form, but experiments show that is exactly the form
+ # required by find_library for the MinGW case. Net result: no
+ # conversion necessary for either Linux or MinGW.
find_library(libstdcxx_full_path NAMES stdc++ PATHS ${CXX_library_path})
message(STATUS "libstdcxx_full_path = ${libstdcxx_full_path}")
else(CXX_library_path_string MATCHES "^LIBRARY_PATH=")
@@ -266,10 +299,16 @@
message(STATUS "CXX_string = ${CXX_string}")
endif(CXX_rc STREQUAL "0" AND CXX_string MATCHES "LIBRARY_PATH=")
if(NOT libstdcxx_full_path)
- message(STATUS "WARNING: failed to find viable C++ compiler library so pkg-config link flags will be incomplete")
+ message(STATUS "WARNING: failed to find libstdc++ so pkg-config link flags will be incomplete")
endif(NOT libstdcxx_full_path)
-endif(NOT BUILD_SHARED_LIBS)
+endif(ENABLE_cxx AND NOT BUILD_SHARED_LIBS)
+# Transform current information in libplplot${LIB_TAG}_LINK_LIBRARIES
+# into pkg-config (libplplot${LIB_TAG}_LINK_FLAGS) form. Both variables
+# will have data added to them afterward due to the internal PLplot libraries
+# which have a different pkg-config treatment than the external libraries
+# dealt with here.
+
if(libstdcxx_full_path)
pkg_config_link_flags(
libplplot${LIB_TAG}_LINK_FLAGS
@@ -282,24 +321,20 @@
)
endif(libstdcxx_full_path)
+# The above completes dealing with the external libraries. Now
+# deal with the internal libraries that are built by the PLplot
+# build system.
+
if(WITH_CSA)
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES csirocsa)
set(
- libplplot${LIB_TAG}_LINK_LIBRARIES
- ${libplplot${LIB_TAG}_LINK_LIBRARIES}
- csirocsa
- )
- set(
libplplot${LIB_TAG}_LINK_FLAGS
"${libplplot${LIB_TAG}_LINK_FLAGS} -lcsirocsa"
)
endif(WITH_CSA)
if(PL_HAVE_QHULL)
- set(
- libplplot${LIB_TAG}_LINK_LIBRARIES
- ${libplplot${LIB_TAG}_LINK_LIBRARIES}
- csironn
- )
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES csironn)
if(QHULL_RPATH)
set(
libplplot${LIB_TAG}_LINK_FLAGS
@@ -317,11 +352,11 @@
)
# Needed by the traditional pkg-config approach for installed examples
# as well as the new CMake-based build system for the installed examples.
- set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${QHULL_RPATH})
+ list(APPEND LIB_INSTALL_RPATH ${QHULL_RPATH})
endif(PL_HAVE_QHULL)
if(NOT ENABLE_DYNDRIVERS AND PLD_cgm)
- list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES nistcd)
+ list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES nistcd)
set(
libplplot${LIB_TAG}_LINK_FLAGS
"${libplplot${LIB_TAG}_LINK_FLAGS} -lnistcd"
@@ -329,84 +364,12 @@
include_directories(${CMAKE_SOURCE_DIR}/lib/nistcd)
endif(NOT ENABLE_DYNDRIVERS AND PLD_cgm)
+list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES qsastime)
set(
- libplplot${LIB_TAG}_LINK_LIBRARIES
- ${libplplot${LIB_TAG}_LINK_LIBRARIES}
- qsastime
- )
-set(
libplplot${LIB_TAG}_LINK_FLAGS
"${libplplot${LIB_TAG}_LINK_FLAGS} -lqsastime"
)
-if(WITH_FREETYPE)
- get_source_file_property(PLFREETYPE_COMPILE_PROPS plfreetype.c COMPILE_FLAGS)
- # Deal with NOTFOUND case.
- if(NOT PLFREETYPE_COMPILE_PROPS)
- set(PLFREETYPE_COMPILE_PROPS)
- endif(NOT PLFREETYPE_COMPILE_PROPS)
- set_source_files_properties(plfreetype.c PROPERTIES COMPILE_FLAGS "${PLFREETYPE_COMPILE_PROPS} -I${FREETYPE_INCLUDE_DIR}")
- set(
- libplplot${LIB_TAG}_LINK_LIBRARIES
- ${libplplot${LIB_TAG}_LINK_LIBRARIES}
- ${FREETYPE_LIBRARIES}
- )
-
- # Convert to -L... -l... form.
- string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
- _FREETYPE_LINK_FLAGS
- ${FREETYPE_LIBRARIES}
- )
- string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
- FREETYPE_LINK_FLAGS
- ${_FREETYPE_LINK_FLAGS}
- )
- set(
- libplplot${LIB_TAG}_LINK_FLAGS
- "${libplplot${LIB_TAG}_LINK_FLAGS} ${FREETYPE_LINK_FLAGS}"
- )
-endif(WITH_FREETYPE)
-
-if(HAVE_SHAPELIB)
- get_source_file_property(PLMAP_COMPILE_PROPS plmap.c COMPILE_FLAGS)
- # Deal with NOTFOUND case.
- if(NOT PLMAP_COMPILE_PROPS)
- set(PLMAP_COMPILE_PROPS)
- endif(NOT PLMAP_COMPILE_PROPS)
- set_source_files_properties(plmap.c
- PROPERTIES
- COMPILE_FLAGS "${PLMAP_COMPILE_PROPS} -I${SHAPELIB_INCLUDE_DIR}"
- )
- if(HAVE_SAHOOKS)
- set_source_files_properties(plmap.c
- PROPERTIES
- COMPILE_DEFINITIONS HAVE_SAHOOKS
- )
- endif(HAVE_SAHOOKS)
-
- set(
- libplplot${LIB_TAG}_LINK_LIBRARIES
- ${libplplot${LIB_TAG}_LINK_LIBRARIES}
- ${SHAPELIB_LIBRARIES}
- )
-
- set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${SHAPELIB_RPATH})
-
- # Convert to -L... -l... form.
- string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
- _SHAPELIB_LINK_FLAGS
- ${SHAPELIB_LIBRARIES}
- )
- string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
- SHAPELIB_LINK_FLAGS
- ${_SHAPELIB_LINK_FLAGS}
- )
- set(
- libplplot${LIB_TAG}_LINK_FLAGS
- "${libplplot${LIB_TAG}_LINK_FLAGS} ${SHAPELIB_LINK_FLAGS}"
- )
-endif(HAVE_SHAPELIB)
-
#message(STATUS
#"libplplot${LIB_TAG}_LINK_LIBRARIES = ${libplplot${LIB_TAG}_LINK_LIBRARIES}"
#)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|