summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@sap.com>2017-12-12 08:41:16 (GMT)
committerMarc Chevrier <marc.chevrier@sap.com>2017-12-12 08:41:16 (GMT)
commit362a1f336d29fb315db937dcce4dbd894bbffd2d (patch)
tree0f384c4fe6b9b8f553adde7e08467e0c053ad31e /Modules
parentc365a0787058e41f0e96f4dd2447cb71a17f7696 (diff)
downloadCMake-362a1f336d29fb315db937dcce4dbd894bbffd2d.zip
CMake-362a1f336d29fb315db937dcce4dbd894bbffd2d.tar.gz
CMake-362a1f336d29fb315db937dcce4dbd894bbffd2d.tar.bz2
FindPerlLibs: refactoring
Use a dedicated function (perl_get_info) to retrieve various configuration information
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPerlLibs.cmake187
1 files changed, 40 insertions, 147 deletions
diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake
index 2767325..86d5774 100644
--- a/Modules/FindPerlLibs.cmake
+++ b/Modules/FindPerlLibs.cmake
@@ -33,6 +33,7 @@
# ::
#
# PERL_SITESEARCH = path to the sitesearch install dir (-V:installsitesearch)
+# PERL_SITEARCH = path to the sitelib install directory (-V:installsitearch)
# PERL_SITELIB = path to the sitelib install directory (-V:installsitelib)
# PERL_VENDORARCH = path to the vendor arch install directory (-V:installvendorarch)
# PERL_VENDORLIB = path to the vendor lib install directory (-V:installvendorlib)
@@ -46,182 +47,74 @@
include(${CMAKE_CURRENT_LIST_DIR}/FindPerl.cmake)
if (PERL_EXECUTABLE)
- ### PERL_PREFIX
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:prefix
- OUTPUT_VARIABLE
- PERL_PREFIX_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_PREFIX_RESULT_VARIABLE
- )
- if (NOT PERL_PREFIX_RESULT_VARIABLE)
- string(REGEX REPLACE "prefix='([^']+)'.*" "\\1" PERL_PREFIX ${PERL_PREFIX_OUTPUT_VARIABLE})
- endif ()
+ function (perl_get_info _pgi_info tag)
+ cmake_parse_arguments(_PGI "IS_PATH" "" "" ${ARGN})
- ### PERL_ARCHNAME
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:archname
- OUTPUT_VARIABLE
- PERL_ARCHNAME_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_ARCHNAME_RESULT_VARIABLE
- )
- if (NOT PERL_ARCHNAME_RESULT_VARIABLE)
- string(REGEX REPLACE "archname='([^']+)'.*" "\\1" PERL_ARCHNAME ${PERL_ARCHNAME_OUTPUT_VARIABLE})
- endif ()
+ set (${_pgi_info} NOTFOUND PARENT_SCOPE)
+ execute_process(COMMAND "${PERL_EXECUTABLE}" -V:${tag}
+ OUTPUT_VARIABLE result
+ RESULT_VARIABLE status)
+ if (NOT status)
+ string(REGEX REPLACE "${tag}='([^']*)'.*" "\\1" result "${result}")
+ if (_PGI_IS_PATH)
+ file(TO_CMAKE_PATH "${result}" result)
+ endif()
+ set (${_pgi_info} "${result}" PARENT_SCOPE)
+ endif ()
+ endfunction()
+
+ ### PERL_PREFIX
+ perl_get_info(PERL_PREFIX prefix IS_PATH)
+
+ ### PERL_ARCHNAME
+ perl_get_info(PERL_ARCHNAME archname)
### PERL_EXTRA_C_FLAGS
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:cppflags
- OUTPUT_VARIABLE
- PERL_CPPFLAGS_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_CPPFLAGS_RESULT_VARIABLE
- )
- if (NOT PERL_CPPFLAGS_RESULT_VARIABLE)
- string(REGEX REPLACE "cppflags='([^']+)'.*" "\\1" PERL_EXTRA_C_FLAGS ${PERL_CPPFLAGS_OUTPUT_VARIABLE})
- endif ()
+ perl_get_info(PERL_EXTRA_C_FLAGS cppflags)
### PERL_SITESEARCH
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installsitesearch
- OUTPUT_VARIABLE
- PERL_SITESEARCH_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_SITESEARCH_RESULT_VARIABLE
- )
- if (NOT PERL_SITESEARCH_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITESEARCH ${PERL_SITESEARCH_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_SITESEARCH}" PERL_SITESEARCH)
- endif ()
+ perl_get_info(PERL_SITESEARCH installsitesearch IS_PATH)
+
+ ### PERL_SITEARCH
+ perl_get_info(PERL_SITEARCH installsitearch IS_PATH)
### PERL_SITELIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installsitelib
- OUTPUT_VARIABLE
- PERL_SITELIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_SITELIB_RESULT_VARIABLE
- )
- if (NOT PERL_SITELIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITELIB ${PERL_SITELIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_SITELIB}" PERL_SITELIB)
- endif ()
+ perl_get_info(PERL_SITELIB installsitelib IS_PATH)
### PERL_VENDORARCH
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installvendorarch
- OUTPUT_VARIABLE
- PERL_VENDORARCH_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_VENDORARCH_RESULT_VARIABLE
- )
- if (NOT PERL_VENDORARCH_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORARCH ${PERL_VENDORARCH_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_VENDORARCH}" PERL_VENDORARCH)
- endif ()
+ perl_get_info(PERL_VENDORARCH installvendorarch IS_PATH)
### PERL_VENDORLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installvendorlib
- OUTPUT_VARIABLE
- PERL_VENDORLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_VENDORLIB_RESULT_VARIABLE
- )
- if (NOT PERL_VENDORLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORLIB ${PERL_VENDORLIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_VENDORLIB}" PERL_VENDORLIB)
- endif ()
+ perl_get_info(PERL_VENDORLIB installvendorlib IS_PATH)
### PERL_ARCHLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:archlib
- OUTPUT_VARIABLE
- PERL_ARCHLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_ARCHLIB_RESULT_VARIABLE
- )
- if (NOT PERL_ARCHLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "archlib='([^']+)'.*" "\\1" PERL_ARCHLIB ${PERL_ARCHLIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_ARCHLIB}" PERL_ARCHLIB)
- endif ()
+ perl_get_info(PERL_ARCHLIB archlib IS_PATH)
### PERL_PRIVLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:privlib
- OUTPUT_VARIABLE
- PERL_PRIVLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_PRIVLIB_RESULT_VARIABLE
- )
- if (NOT PERL_PRIVLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "privlib='([^']+)'.*" "\\1" PERL_PRIVLIB ${PERL_PRIVLIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_PRIVLIB}" PERL_PRIVLIB)
- endif ()
+ perl_get_info(PERL_PRIVLIB privlib IS_PATH)
### PERL_UPDATE_ARCHLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installarchlib
- OUTPUT_VARIABLE
- PERL_UPDATE_ARCHLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_UPDATE_ARCHLIB_RESULT_VARIABLE
- )
- if (NOT PERL_UPDATE_ARCHLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_UPDATE_ARCHLIB ${PERL_UPDATE_ARCHLIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_UPDATE_ARCHLIB}" PERL_UPDATE_ARCHLIB)
- endif ()
+ perl_get_info(PERL_UPDATE_ARCHLIB installarchlib IS_PATH)
### PERL_UPDATE_PRIVLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installprivlib
- OUTPUT_VARIABLE
- PERL_UPDATE_PRIVLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_UPDATE_PRIVLIB_RESULT_VARIABLE
- )
- if (NOT PERL_UPDATE_PRIVLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_UPDATE_PRIVLIB ${PERL_UPDATE_PRIVLIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_UPDATE_PRIVLIB}" PERL_UPDATE_PRIVLIB)
- endif ()
+ perl_get_info(PERL_UPDATE_PRIVLIB installprivlib IS_PATH)
### PERL_POSSIBLE_LIBRARY_NAMES
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:libperl
- OUTPUT_VARIABLE
- PERL_LIBRARY_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_LIBRARY_RESULT_VARIABLE
- )
- if (NOT PERL_LIBRARY_RESULT_VARIABLE)
- string(REGEX REPLACE "libperl='([^']+)'.*" "\\1" PERL_POSSIBLE_LIBRARY_NAMES ${PERL_LIBRARY_OUTPUT_VARIABLE})
- else ()
+ perl_get_info(PERL_POSSIBLE_LIBRARY_NAMES libperl)
+ if (NOT PERL_POSSIBLE_LIBRARY_NAMES)
set(PERL_POSSIBLE_LIBRARY_NAMES perl${PERL_VERSION_STRING} perl)
- endif ()
+ endif()
### PERL_INCLUDE_PATH
find_path(PERL_INCLUDE_PATH
NAMES
perl.h
PATHS
- ${PERL_UPDATE_ARCHLIB}/CORE
- ${PERL_ARCHLIB}/CORE
+ "${PERL_UPDATE_ARCHLIB}/CORE"
+ "${PERL_ARCHLIB}/CORE"
/usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl5/${PERL_VERSION_STRING}/CORE
@@ -233,8 +126,8 @@ if (PERL_EXECUTABLE)
NAMES
${PERL_POSSIBLE_LIBRARY_NAMES}
PATHS
- ${PERL_UPDATE_ARCHLIB}/CORE
- ${PERL_ARCHLIB}/CORE
+ "${PERL_UPDATE_ARCHLIB}/CORE"
+ "${PERL_ARCHLIB}/CORE"
/usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl5/${PERL_VERSION_STRING}/CORE