From: <and...@us...> - 2007-07-18 18:03:50
|
Revision: 7754 http://plplot.svn.sourceforge.net/plplot/?rev=7754&view=rev Author: andrewross Date: 2007-07-18 11:03:53 -0700 (Wed, 18 Jul 2007) Log Message: ----------- Fix pc_transform_link_flags to correctly handle blank input strings. Modified Paths: -------------- trunk/cmake/modules/pkg-config.cmake Modified: trunk/cmake/modules/pkg-config.cmake =================================================================== --- trunk/cmake/modules/pkg-config.cmake 2007-07-17 15:36:31 UTC (rev 7753) +++ trunk/cmake/modules/pkg-config.cmake 2007-07-18 18:03:53 UTC (rev 7754) @@ -121,7 +121,7 @@ string( REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\${suffix}" "-L\\1 -l\\2" ${_link_flags_out} - ${${_link_flags_out}} + "${${_link_flags_out}}" ) #message("(${suffix}) ${_link_flags_out} = ${${_link_flags_out}}") endforeach(suffix ${suffix_list}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2008-01-25 19:23:51
|
Revision: 8174 http://plplot.svn.sourceforge.net/plplot/?rev=8174&view=rev Author: airwin Date: 2008-01-25 11:23:57 -0800 (Fri, 25 Jan 2008) Log Message: ----------- Rename pc_transform_link_flags macro to pkg-config_link_flags. Put in placeholder (not implemented or used yet) for cmake_link_flags macro. Modified Paths: -------------- trunk/cmake/modules/pkg-config.cmake Modified: trunk/cmake/modules/pkg-config.cmake =================================================================== --- trunk/cmake/modules/pkg-config.cmake 2008-01-25 19:21:45 UTC (rev 8173) +++ trunk/cmake/modules/pkg-config.cmake 2008-01-25 19:23:57 UTC (rev 8174) @@ -20,9 +20,11 @@ # Module for determining pkg-config configuration variables related to the # install-tree build of the examples. # Also create useful macros called pkg_check_pkgconfig to emulate the -# pkgconfig macro using the pkg_check_modules macro and -# pc_transform_link_flags to process link flags into standard form for -# the configured *.pc files. +# pkgconfig macro using the pkg_check_modules macro, +# cmake_to_pkg_config_link_flags to process CMake link flags into +# pkg-config standard form for the configured output *.pc files, and +# pkg_config_to_cmake_link_flags to process input link flags delivered +# by pkg-config into CMake standard form. # The following variables are set: # PKG_CONFIG_EXECUTABLE - name of pkg-config executable, but can also be @@ -91,9 +93,9 @@ #message("${_cflags} = ${${_cflags}}") endmacro(pkg_check_pkgconfig) -macro(pc_transform_link_flags _link_flags_out _link_flags_in) - # Transform link flags into a form that is suitable to be used in - # pkg-config (*.pc) files. +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. #message("(original link flags) = ${_link_flags_in}") @@ -138,4 +140,53 @@ #message("(frameworks) ${_link_flags_out} = ${${_link_flags_out}}") endif(APPLE) -endmacro(pc_transform_link_flags) +endmacro(pkg_config_link_flags) + +macro(cmake_link_flags _link_flags_out _link_flags_in) + # Transform link flags delivered by pkg-config into the best form + # for CMake. + # N.B. ${_link_flags_in} must be a string and not a list. + + #message("(original link flags) = ${_link_flags_in}") + # Convert link flags to a blank-delimited string. + string(REGEX REPLACE ";" " " ${_link_flags_out} "${_link_flags_in}") + #message("(blanks) ${_link_flags_out} = ${${_link_flags_out}}") + + # Replace actual library names with the -LPATHNAME and -lLIBRARYNAME form + # 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 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}) + string( + 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) + # For Mac OS X transform frameworks information into correct form. + string( + REGEX REPLACE + "/System/Library/Frameworks/([^ ]*)\\.framework" + "-framework \\1" + ${_link_flags_out} + ${${_link_flags_out}} + ) + #message("(frameworks) ${_link_flags_out} = ${${_link_flags_out}}") + endif(APPLE) + +endmacro(cmake_link_flags) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2008-01-26 01:40:08
|
Revision: 8175 http://plplot.svn.sourceforge.net/plplot/?rev=8175&view=rev Author: airwin Date: 2008-01-25 17:40:13 -0800 (Fri, 25 Jan 2008) Log Message: ----------- Implement a working version of the cmake_link_flags macro for determining the best form (full library pathnames) of CMake link flags from the -L and -l options delivered by pkg-config. Modified Paths: -------------- trunk/cmake/modules/pkg-config.cmake Modified: trunk/cmake/modules/pkg-config.cmake =================================================================== --- trunk/cmake/modules/pkg-config.cmake 2008-01-25 19:23:57 UTC (rev 8174) +++ trunk/cmake/modules/pkg-config.cmake 2008-01-26 01:40:13 UTC (rev 8175) @@ -145,48 +145,63 @@ macro(cmake_link_flags _link_flags_out _link_flags_in) # Transform link flags delivered by pkg-config into the best form # for CMake. + # N.B. may need revision for windows since the current assumption + # is pkg-config delivers link flags using the -L and -l options which + # may not be the case for windows. # N.B. ${_link_flags_in} must be a string and not a list. #message("(original link flags) = ${_link_flags_in}") - # Convert link flags to a blank-delimited string. - string(REGEX REPLACE ";" " " ${_link_flags_out} "${_link_flags_in}") - #message("(blanks) ${_link_flags_out} = ${${_link_flags_out}}") + # Convert link flags to a list. + string(REGEX REPLACE " " ";" _link_flags_list "${_link_flags_in}") + # Extract list of directories from -L options. + list(LENGTH _link_flags_list _link_flags_length) + math(EXPR _link_flags_length "${_link_flags_length} - 1") + set(_index_list) + set(_link_directory_list) + foreach(_list_index RANGE ${_link_flags_length}) + list(GET _link_flags_list ${_list_index} _list_element) + string(REGEX REPLACE "^-L" "" _list_element1 ${_list_element}) + if(_list_element STREQUAL "-L${_list_element1}") + list(APPEND _index_list ${_list_index}) + list(APPEND _link_directory_list ${_list_element1}) + endif(_list_element STREQUAL "-L${_list_element1}") + endforeach(_list_index RANGE ${_link_flags_length}) + # Remove -L options from list. + list(REMOVE_AT _link_flags_list ${_index_list}) + #message("_link_directory_list = ${_link_directory_list}") + #message("_link_flags_list (without -L options) = ${_link_flags_list}") - # Replace actual library names with the -LPATHNAME and -lLIBRARYNAME form - # 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 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}) - string( - 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) - # For Mac OS X transform frameworks information into correct form. - string( - REGEX REPLACE - "/System/Library/Frameworks/([^ ]*)\\.framework" - "-framework \\1" - ${_link_flags_out} - ${${_link_flags_out}} - ) - #message("(frameworks) ${_link_flags_out} = ${${_link_flags_out}}") - endif(APPLE) - + # Derive ${_link_flags_out} from _link_flags_list with -l options + # replaced by complete pathname of library. + list(LENGTH _link_flags_list _link_flags_length) + math(EXPR _link_flags_length "${_link_flags_length} - 1") + set(${_link_flags_out}) + foreach(_list_index RANGE ${_link_flags_length}) + list(GET _link_flags_list ${_list_index} _list_element) + string(REGEX REPLACE "^-l" "" _list_element1 ${_list_element}) + if(_list_element STREQUAL "-l${_list_element1}") + set(_library_pathname "_library_pathname-NOTFOUND") + find_library( + _library_pathname + ${_list_element1} + PATHS ${_link_directory_list} + NO_DEFAULT_PATH + ) + if(NOT _library_pathname) + message( + "Cannot find library corresponding to linker option ${_list_element}" + ) + message( + "original link flags delivered by pkg-config = ${_link_flags_in}" + ) + message(FATAL_ERROR "FATAL ERROR in cmake_link_flags macro") + endif(NOT _library_pathname) + list(APPEND ${_link_flags_out} ${_library_pathname}) + else(_list_element STREQUAL "-L${_list_element1}") + # link options that are not -L or -l passed through in correct order + # in ${_link_flags_out}. + list(APPEND ${_link_flags_out} ${_list_element}) + endif(_list_element STREQUAL "-l${_list_element1}") + endforeach(_list_index RANGE ${_link_flags_length}) + #message("${_link_flags_out} = ${${_link_flags_out}}") endmacro(cmake_link_flags) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2008-01-26 21:36:02
|
Revision: 8177 http://plplot.svn.sourceforge.net/plplot/?rev=8177&view=rev Author: airwin Date: 2008-01-26 13:36:04 -0800 (Sat, 26 Jan 2008) Log Message: ----------- Make cmake_link_flags macro much more robust. pkg_check_pkgconfig macro processes its link_flags with cmake_link_flags macro. Modified Paths: -------------- trunk/cmake/modules/pkg-config.cmake Modified: trunk/cmake/modules/pkg-config.cmake =================================================================== --- trunk/cmake/modules/pkg-config.cmake 2008-01-26 01:52:13 UTC (rev 8176) +++ trunk/cmake/modules/pkg-config.cmake 2008-01-26 21:36:04 UTC (rev 8177) @@ -62,7 +62,8 @@ macro(pkg_check_pkgconfig _package _include_DIR _link_DIR _link_FLAGS _cflags) # Similar to legacy pkgconfig only these results are derived # from pkg_check_modules and therefore are returned as lists rather than - # blank-delimited strings. + # blank-delimited strings. Also, the _link_FLAGS value is converted + # to the preferred CMake form via the cmake_link_flags macro. # N.B. if using this macro in more than one context, cache clashes will # occur unless optional trailing prefix argument is specified to distinguish @@ -76,7 +77,7 @@ if (${_prefix}_FOUND) set(${_include_DIR} ${${_prefix}_INCLUDE_DIRS}) set(${_link_DIR} ${${_prefix}_LIBRARY_DIRS}) - set(${_link_FLAGS} ${${_prefix}_LDFLAGS}) + cmake_link_flags(${_link_FLAGS} "${${_prefix}_LDFLAGS}") set(${_cflags} ${${_prefix}_CFLAGS}) set(_return_VALUE 0) else(${_prefix}_FOUND) @@ -150,58 +151,73 @@ # may not be the case for windows. # N.B. ${_link_flags_in} must be a string and not a list. - #message("(original link flags) = ${_link_flags_in}") - # Convert link flags to a list. - string(REGEX REPLACE " " ";" _link_flags_list "${_link_flags_in}") - # Extract list of directories from -L options. - list(LENGTH _link_flags_list _link_flags_length) - math(EXPR _link_flags_length "${_link_flags_length} - 1") - set(_index_list) - set(_link_directory_list) - foreach(_list_index RANGE ${_link_flags_length}) - list(GET _link_flags_list ${_list_index} _list_element) - string(REGEX REPLACE "^-L" "" _list_element1 ${_list_element}) - if(_list_element STREQUAL "-L${_list_element1}") - list(APPEND _index_list ${_list_index}) - list(APPEND _link_directory_list ${_list_element1}) - endif(_list_element STREQUAL "-L${_list_element1}") - endforeach(_list_index RANGE ${_link_flags_length}) - # Remove -L options from list. - list(REMOVE_AT _link_flags_list ${_index_list}) - #message("_link_directory_list = ${_link_directory_list}") - #message("_link_flags_list (without -L options) = ${_link_flags_list}") - - # Derive ${_link_flags_out} from _link_flags_list with -l options - # replaced by complete pathname of library. - list(LENGTH _link_flags_list _link_flags_length) - math(EXPR _link_flags_length "${_link_flags_length} - 1") - set(${_link_flags_out}) - foreach(_list_index RANGE ${_link_flags_length}) - list(GET _link_flags_list ${_list_index} _list_element) - string(REGEX REPLACE "^-l" "" _list_element1 ${_list_element}) - if(_list_element STREQUAL "-l${_list_element1}") - set(_library_pathname "_library_pathname-NOTFOUND") - find_library( - _library_pathname - ${_list_element1} - PATHS ${_link_directory_list} - NO_DEFAULT_PATH - ) - if(NOT _library_pathname) - message( - "Cannot find library corresponding to linker option ${_list_element}" - ) - message( - "original link flags delivered by pkg-config = ${_link_flags_in}" - ) - message(FATAL_ERROR "FATAL ERROR in cmake_link_flags macro") - endif(NOT _library_pathname) - list(APPEND ${_link_flags_out} ${_library_pathname}) - else(_list_element STREQUAL "-L${_list_element1}") - # link options that are not -L or -l passed through in correct order - # in ${_link_flags_out}. - list(APPEND ${_link_flags_out} ${_list_element}) - endif(_list_element STREQUAL "-l${_list_element1}") - endforeach(_list_index RANGE ${_link_flags_length}) - #message("${_link_flags_out} = ${${_link_flags_out}}") + if("${_link_flags_in}" STREQUAL "") + set(${_link_flags_out}) + else("${_link_flags_in}" STREQUAL ""}) + #message("(original link flags) = ${_link_flags_in}") + # Convert link flags to a list. + string(REGEX REPLACE " " ";" _link_flags_list "${_link_flags_in}") + # Extract list of directories from -L options. + list(LENGTH _link_flags_list _link_flags_length) + math(EXPR _link_flags_length "${_link_flags_length} - 1") + set(_index_list) + set(_link_directory_list) + foreach(_list_index RANGE ${_link_flags_length}) + list(GET _link_flags_list ${_list_index} _list_element) + string(REGEX REPLACE "^-L" "" _list_element1 ${_list_element}) + if(_list_element STREQUAL "-L${_list_element1}") + list(APPEND _index_list ${_list_index}) + list(APPEND _link_directory_list ${_list_element1}) + endif(_list_element STREQUAL "-L${_list_element1}") + endforeach(_list_index RANGE ${_link_flags_length}) + #message("_index_list = ${_index_list}") + if("${_index_list}" STREQUAL "") + else("${_index_list}" STREQUAL "") + # Remove -L options from list. + list(REMOVE_AT _link_flags_list ${_index_list}) + endif("${_index_list}" STREQUAL "") + #message("_link_directory_list = ${_link_directory_list}") + #message("_link_flags_list (without -L options) = ${_link_flags_list}") + + # Derive ${_link_flags_out} from _link_flags_list with -l options + # replaced by complete pathname of library. + list(LENGTH _link_flags_list _link_flags_length) + math(EXPR _link_flags_length "${_link_flags_length} - 1") + set(${_link_flags_out}) + foreach(_list_index RANGE ${_link_flags_length}) + list(GET _link_flags_list ${_list_index} _list_element) + string(REGEX REPLACE "^-l" "" _list_element1 ${_list_element}) + if(_list_element STREQUAL "-l${_list_element1}") + set(_library_pathname "_library_pathname-NOTFOUND") + find_library( + _library_pathname + ${_list_element1} + PATHS ${_link_directory_list} + NO_DEFAULT_PATH + ) + # Try second time (without NO_DEFAULT_PATH) just in case pkg-config + # specified some system libraries without corresponding -L options. + find_library( + _library_pathname + ${_list_element1} + PATHS ${_link_directory_list} + ) + if(NOT _library_pathname) + message( + "Cannot find library corresponding to linker option ${_list_element}" + ) + message( + "original link flags delivered by pkg-config = ${_link_flags_in}" + ) + message(FATAL_ERROR "FATAL ERROR in cmake_link_flags macro") + endif(NOT _library_pathname) + list(APPEND ${_link_flags_out} ${_library_pathname}) + else(_list_element STREQUAL "-L${_list_element1}") + # link options that are not -L or -l passed through in correct order + # in ${_link_flags_out}. + list(APPEND ${_link_flags_out} ${_list_element}) + endif(_list_element STREQUAL "-l${_list_element1}") + endforeach(_list_index RANGE ${_link_flags_length}) + #message("${_link_flags_out} = ${${_link_flags_out}}") + endif("${_link_flags_in}" STREQUAL "") endmacro(cmake_link_flags) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2008-04-17 18:26:16
|
Revision: 8377 http://plplot.svn.sourceforge.net/plplot/?rev=8377&view=rev Author: airwin Date: 2008-04-17 11:26:11 -0700 (Thu, 17 Apr 2008) Log Message: ----------- Tweak commentary. Modified Paths: -------------- trunk/cmake/modules/pkg-config.cmake Modified: trunk/cmake/modules/pkg-config.cmake =================================================================== --- trunk/cmake/modules/pkg-config.cmake 2008-04-17 17:54:47 UTC (rev 8376) +++ trunk/cmake/modules/pkg-config.cmake 2008-04-17 18:26:11 UTC (rev 8377) @@ -20,10 +20,10 @@ # Module for determining pkg-config configuration variables related to the # install-tree build of the examples. # Also create useful macros called pkg_check_pkgconfig to emulate the -# pkgconfig macro using the pkg_check_modules macro, -# cmake_to_pkg_config_link_flags to process CMake link flags into +# pkgconfig macro using the pkg_check_modules macro; +# pkg_config_link_flags to process CMake link flags into # pkg-config standard form for the configured output *.pc files, and -# pkg_config_to_cmake_link_flags to process input link flags delivered +# cmake_link_flags to process input link flags delivered # by pkg-config into CMake standard form. # The following variables are set: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2008-05-09 18:55:34
|
Revision: 8403 http://plplot.svn.sourceforge.net/plplot/?rev=8403&view=rev Author: airwin Date: 2008-05-09 11:55:41 -0700 (Fri, 09 May 2008) Log Message: ----------- Allow for empty elements in the lists being processed. Modified Paths: -------------- trunk/cmake/modules/pkg-config.cmake Modified: trunk/cmake/modules/pkg-config.cmake =================================================================== --- trunk/cmake/modules/pkg-config.cmake 2008-05-09 18:28:58 UTC (rev 8402) +++ trunk/cmake/modules/pkg-config.cmake 2008-05-09 18:55:41 UTC (rev 8403) @@ -164,7 +164,7 @@ set(_link_directory_list) foreach(_list_index RANGE ${_link_flags_length}) list(GET _link_flags_list ${_list_index} _list_element) - string(REGEX REPLACE "^-L" "" _list_element1 ${_list_element}) + string(REGEX REPLACE "^-L" "" _list_element1 "${_list_element}") if(_list_element STREQUAL "-L${_list_element1}") list(APPEND _index_list ${_list_index}) list(APPEND _link_directory_list ${_list_element1}) @@ -186,7 +186,7 @@ set(${_link_flags_out}) foreach(_list_index RANGE ${_link_flags_length}) list(GET _link_flags_list ${_list_index} _list_element) - string(REGEX REPLACE "^-l" "" _list_element1 ${_list_element}) + string(REGEX REPLACE "^-l" "" _list_element1 "${_list_element}") if(_list_element STREQUAL "-l${_list_element1}") set(_library_pathname "_library_pathname-NOTFOUND") find_library( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2008-06-10 17:43:29
|
Revision: 8473 http://plplot.svn.sourceforge.net/plplot/?rev=8473&view=rev Author: airwin Date: 2008-06-10 10:43:37 -0700 (Tue, 10 Jun 2008) Log Message: ----------- Preserve blank-delimited library flags as single elements of the output list in the cmake_link_flags macro. Modified Paths: -------------- trunk/cmake/modules/pkg-config.cmake Modified: trunk/cmake/modules/pkg-config.cmake =================================================================== --- trunk/cmake/modules/pkg-config.cmake 2008-06-10 17:25:05 UTC (rev 8472) +++ trunk/cmake/modules/pkg-config.cmake 2008-06-10 17:43:37 UTC (rev 8473) @@ -155,8 +155,10 @@ set(${_link_flags_out}) else("${_link_flags_in}" STREQUAL ""}) #message("(original link flags) = ${_link_flags_in}") - # Convert link flags to a list. - string(REGEX REPLACE " " ";" _link_flags_list "${_link_flags_in}") + # Convert link flags to a list. Note some link flags are blank-delimited + # (such as "-framework whatever") so preserve those by splitting into + # separate list elements only if the next element starts with a hyphen. + string(REGEX REPLACE " -" ";-" _link_flags_list "${_link_flags_in}") # Extract list of directories from -L options. list(LENGTH _link_flags_list _link_flags_length) math(EXPR _link_flags_length "${_link_flags_length} - 1") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |