2020-12-02 05:37:26 +08:00
#[===[.md:
# vcpkg_configure_make
C o n f i g u r e c o n f i g u r e f o r D e b u g a n d R e l e a s e b u i l d s o f a p r o j e c t .
## Usage
` ` ` c m a k e
vcpkg_configure_make (
S O U R C E _ P A T H < $ { S O U R C E _ P A T H } >
[ A U T O C O N F I G ]
[ U S E _ W R A P P E R S ]
[ D E T E R M I N E _ B U I L D _ T R I P L E T ]
[ B U I L D _ T R I P L E T " - - h o s t = x 6 4 - - b u i l d = i 6 8 6 - u n k n o w n - p c " ]
[ N O _ A D D I T I O N A L _ P A T H S ]
[ C O N F I G _ D E P E N D E N T _ E N V I R O N M E N T < S O M E _ V A R > . . . ]
[ C O N F I G U R E _ E N V I R O N M E N T _ V A R I A B L E S < S O M E _ E N V V A R > . . . ]
[ A D D _ B I N _ T O _ P A T H ]
[ N O _ D E B U G ]
[ S K I P _ C O N F I G U R E ]
[ P R O J E C T _ S U B P A T H < $ { P R O J _ S U B P A T H } > ]
[ P R E R U N _ S H E L L < $ { S H E L L _ P A T H } > ]
[ O P T I O N S < - D U S E _ T H I S _ I N _ A L L _ B U I L D S = 1 > . . . ]
[ O P T I O N S _ R E L E A S E < - D O P T I M I Z E = 1 > . . . ]
[ O P T I O N S _ D E B U G < - D D E B U G G A B L E = 1 > . . . ]
)
` ` `
## Parameters
### SOURCE_PATH
S p e c i f i e s t h e d i r e c t o r y c o n t a i n i n g t h e ` c o n f i g u r e ` / ` c o n f i g u r e . a c ` .
B y c o n v e n t i o n , t h i s i s u s u a l l y s e t i n t h e p o r t f i l e a s t h e v a r i a b l e ` S O U R C E _ P A T H ` .
### PROJECT_SUBPATH
S p e c i f i e s t h e d i r e c t o r y c o n t a i n i n g t h e ` ` c o n f i g u r e ` / ` c o n f i g u r e . a c ` .
B y c o n v e n t i o n , t h i s i s u s u a l l y s e t i n t h e p o r t f i l e a s t h e v a r i a b l e ` S O U R C E _ P A T H ` .
### SKIP_CONFIGURE
S k i p c o n f i g u r e p r o c e s s
### USE_WRAPPERS
U s e a u t o t o o l s a r - l i b a n d c o m p i l e wrappers ( only applies to windows cl and lib )
### BUILD_TRIPLET
U s e d t o p a s s c u s t o m - - b u i l d / - - t a r g e t / - - h o s t t o c o n f i g u r e . C a n b e g l o b a l l y o v e r w r i t t e n b y V C P K G _ M A K E _ B U I L D _ T R I P L E T
### DETERMINE_BUILD_TRIPLET
F o r p o r t s h a v i n g a c o n f i g u r e s c r i p t f o l l o w i n g t h e a u t o t o o l s r u l e s f o r s e l e c t i n g t h e t r i p l e t
### NO_ADDITIONAL_PATHS
D o n ' t p a s s a n y a d d i t i o n a l p a t h s e x c e p t f o r - - p r e f i x t o t h e c o n f i g u r e c a l l
### AUTOCONFIG
N e e d t o u s e a u t o c o n f i g t o g e n e r a t e c o n f i g u r e f i l e .
### PRERUN_SHELL
S c r i p t t h a t n e e d s t o b e c a l l e d b e f o r e configuration ( do not use for batch files which simply call autoconf or configure )
### ADD_BIN_TO_PATH
A d d s t h e a p p r o p r i a t e R e l e a s e a n d D e b u g ` b i n \ ` d i r e c t o r i e s t o t h e p a t h d u r i n g c o n f i g u r e s u c h t h a t e x e c u t a b l e s c a n r u n a g a i n s t t h e i n - t r e e D L L s .
## DISABLE_VERBOSE_FLAGS
d o n o t p a s s ' - - d i s a b l e - s i l e n t - r u l e s - - v e r b o s e ' t o c o n f i g u r e
### OPTIONS
A d d i t i o n a l o p t i o n s p a s s e d t o c o n f i g u r e d u r i n g t h e c o n f i g u r a t i o n .
### OPTIONS_RELEASE
A d d i t i o n a l o p t i o n s p a s s e d t o c o n f i g u r e d u r i n g t h e R e l e a s e c o n f i g u r a t i o n . T h e s e a r e i n a d d i t i o n t o ` O P T I O N S ` .
### OPTIONS_DEBUG
A d d i t i o n a l o p t i o n s p a s s e d t o c o n f i g u r e d u r i n g t h e D e b u g c o n f i g u r a t i o n . T h e s e a r e i n a d d i t i o n t o ` O P T I O N S ` .
### CONFIG_DEPENDENT_ENVIRONMENT
L i s t o f a d d i t i o n a l c o n f i g u r a t i o n d e p e n d e n t e n v i r o n m e n t v a r i a b l e s t o s e t .
P a s s S O M E V A R t o s e t t h e e n v i r o n m e n t a n d h a v e SOMEVAR_ ( DEBUG|RELEASE ) s e t i n t h e p o r t f i l e t o t h e a p p r o p r i a t e v a l u e s
G e n e r a l e n v i r o n m e n t v a r i a b l e s c a n b e s e t f r o m w i t h i n t h e p o r t f i l e i t s e l f .
### CONFIGURE_ENVIRONMENT_VARIABLES
L i s t o f a d d i t i o n a l e n v i r o n m e n t v a r i a b l e s t o p a s s v i a t h e c o n f i g u r e c a l l .
## Notes
T h i s c o m m a n d s u p p l i e s m a n y c o m m o n a r g u m e n t s t o c o n f i g u r e . T o s e e t h e f u l l l i s t , e x a m i n e t h e s o u r c e .
## Examples
* [ x 2 6 4 ] ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / v c p k g / b l o b / m a s t e r / p o r t s / x 2 6 4 / p o r t f i l e . c m a k e )
* [ t c l ] ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / v c p k g / b l o b / m a s t e r / p o r t s / t c l / p o r t f i l e . c m a k e )
* [ f r e e x l ] ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / v c p k g / b l o b / m a s t e r / p o r t s / f r e e x l / p o r t f i l e . c m a k e )
* [ l i b o s i p 2 ] ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / v c p k g / b l o b / m a s t e r / p o r t s / l i b o s i p 2 / p o r t f i l e . c m a k e )
#]===]
2020-11-11 01:52:02 +08:00
macro ( _vcpkg_determine_host_mingw out_var )
if ( DEFINED ENV{PROCESSOR_ARCHITEW6432} )
set ( HOST_ARCH $ENV{ PROCESSOR_ARCHITEW6432 } )
else ( )
set ( HOST_ARCH $ENV{ PROCESSOR_ARCHITECTURE } )
endif ( )
if ( HOST_ARCH MATCHES "(amd|AMD)64" )
set ( ${ out_var } mingw64 )
elseif ( HOST_ARCH MATCHES "(x|X)86" )
set ( ${ out_var } mingw32 )
else ( )
message ( FATAL_ERROR "Unsupported mingw architecture ${HOST_ARCH} in _vcpkg_determine_autotools_host_cpu!" )
endif ( )
unset ( HOST_ARCH )
endmacro ( )
macro ( _vcpkg_determine_autotools_host_cpu out_var )
2021-05-01 02:26:05 +08:00
# TODO: the host system processor architecture can differ from the host triplet target architecture
2020-11-11 01:52:02 +08:00
if ( DEFINED ENV{PROCESSOR_ARCHITEW6432} )
set ( HOST_ARCH $ENV{ PROCESSOR_ARCHITEW6432 } )
2021-05-01 02:26:05 +08:00
elseif ( DEFINED ENV{PROCESSOR_ARCHITECTURE} )
2020-11-11 01:52:02 +08:00
set ( HOST_ARCH $ENV{ PROCESSOR_ARCHITECTURE } )
2021-05-01 02:26:05 +08:00
else ( )
set ( HOST_ARCH "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}" )
2020-11-11 01:52:02 +08:00
endif ( )
if ( HOST_ARCH MATCHES "(amd|AMD)64" )
set ( ${ out_var } x86_64 )
elseif ( HOST_ARCH MATCHES "(x|X)86" )
set ( ${ out_var } i686 )
elseif ( HOST_ARCH MATCHES "^(ARM|arm)64$" )
set ( ${ out_var } aarch64 )
elseif ( HOST_ARCH MATCHES "^(ARM|arm)$" )
set ( ${ out_var } arm )
else ( )
message ( FATAL_ERROR "Unsupported host architecture ${HOST_ARCH} in _vcpkg_determine_autotools_host_cpu!" )
endif ( )
unset ( HOST_ARCH )
endmacro ( )
macro ( _vcpkg_determine_autotools_target_cpu out_var )
if ( VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)64" )
set ( ${ out_var } x86_64 )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)86" )
set ( ${ out_var } i686 )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)64$" )
set ( ${ out_var } aarch64 )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)$" )
set ( ${ out_var } arm )
else ( )
message ( FATAL_ERROR "Unsupported VCPKG_TARGET_ARCHITECTURE architecture ${VCPKG_TARGET_ARCHITECTURE} in _vcpkg_determine_autotools_target_cpu!" )
endif ( )
endmacro ( )
2021-01-29 11:38:32 +08:00
macro ( _vcpkg_determine_autotools_host_arch_mac out_var )
set ( ${ out_var } "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}" )
endmacro ( )
macro ( _vcpkg_determine_autotools_target_arch_mac out_var )
list ( LENGTH VCPKG_OSX_ARCHITECTURES _num_osx_archs )
if ( _num_osx_archs GREATER_EQUAL 2 )
set ( ${ out_var } "universal" )
else ( )
# Better match the arch behavior of config.guess
# See: https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
if ( VCPKG_OSX_ARCHITECTURES MATCHES "^(ARM|arm)64$" )
set ( ${ out_var } "aarch64" )
else ( )
set ( ${ out_var } "${VCPKG_OSX_ARCHITECTURES}" )
endif ( )
endif ( )
unset ( _num_osx_archs )
endmacro ( )
2020-11-11 01:52:02 +08:00
macro ( _vcpkg_backup_env_variable envvar )
if ( DEFINED ENV{ ${ envvar } } )
set ( ${ envvar } _BACKUP "$ENV{${envvar}}" )
set ( ${ envvar } _PATHLIKE_CONCAT "${VCPKG_HOST_PATH_SEPARATOR}$ENV{${envvar}}" )
else ( )
set ( ${ envvar } _BACKUP )
set ( ${ envvar } _PATHLIKE_CONCAT )
endif ( )
endmacro ( )
macro ( _vcpkg_backup_env_variables )
foreach ( _var ${ ARGV } )
_vcpkg_backup_env_variable ( ${ _var } )
endforeach ( )
endmacro ( )
macro ( _vcpkg_restore_env_variable envvar )
if ( ${ envvar } _BACKUP )
set ( ENV{ ${ envvar } } "${${envvar}_BACKUP}" )
else ( )
unset ( ENV{ ${ envvar } } )
endif ( )
endmacro ( )
macro ( _vcpkg_restore_env_variables )
foreach ( _var ${ ARGV } )
_vcpkg_restore_env_variable ( ${ _var } )
endforeach ( )
endmacro ( )
macro ( _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags _SUFFIX )
string ( REGEX MATCHALL "( |^)-D[^ ]+" CPPFLAGS_ ${ _SUFFIX } "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_SUFFIX}}" )
string ( REGEX MATCHALL "( |^)-D[^ ]+" CXXPPFLAGS_ ${ _SUFFIX } "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_SUFFIX}}" )
list ( JOIN CXXPPFLAGS_ ${ _SUFFIX } "|" CXXREGEX )
if ( CXXREGEX )
list ( FILTER CPPFLAGS_ ${ _SUFFIX } INCLUDE REGEX "(${CXXREGEX})" )
else ( )
set ( CPPFLAGS_ ${ _SUFFIX } )
endif ( )
list ( JOIN CPPFLAGS_ ${ _SUFFIX } "|" CPPREGEX )
list ( JOIN CPPFLAGS_ ${ _SUFFIX } " " CPPFLAGS_ ${ _SUFFIX } )
set ( CPPFLAGS_ ${ _SUFFIX } "${CPPFLAGS_${_SUFFIX}}" )
if ( CPPREGEX )
string ( REGEX REPLACE "(${CPPREGEX})" "" CFLAGS_ ${ _SUFFIX } "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_SUFFIX}}" )
string ( REGEX REPLACE "(${CPPREGEX})" "" CXXFLAGS_ ${ _SUFFIX } "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_SUFFIX}}" )
else ( )
set ( CFLAGS_ ${ _SUFFIX } "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_SUFFIX}}" )
set ( CXXFLAGS_ ${ _SUFFIX } "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_SUFFIX}}" )
endif ( )
string ( REGEX REPLACE " +" " " CPPFLAGS_ ${ _SUFFIX } "${CPPFLAGS_${_SUFFIX}}" )
string ( REGEX REPLACE " +" " " CFLAGS_ ${ _SUFFIX } "${CFLAGS_${_SUFFIX}}" )
string ( REGEX REPLACE " +" " " CXXFLAGS_ ${ _SUFFIX } "${CXXFLAGS_${_SUFFIX}}" )
# libtool has and -R option so we need to guard against -RTC by using -Xcompiler
# while configuring there might be a lot of unknown compiler option warnings due to that
# just ignore them.
string ( REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CFLAGS_ ${ _SUFFIX } "${CFLAGS_${_SUFFIX}}" )
string ( REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CXXFLAGS_ ${ _SUFFIX } "${CXXFLAGS_${_SUFFIX}}" )
string ( STRIP "${CPPFLAGS_${_SUFFIX}}" CPPFLAGS_ ${ _SUFFIX } )
string ( STRIP "${CFLAGS_${_SUFFIX}}" CFLAGS_ ${ _SUFFIX } )
string ( STRIP "${CXXFLAGS_${_SUFFIX}}" CXXFLAGS_ ${ _SUFFIX } )
debug_message ( "CPPFLAGS_${_SUFFIX}: ${CPPFLAGS_${_SUFFIX}}" )
debug_message ( "CFLAGS_${_SUFFIX}: ${CFLAGS_${_SUFFIX}}" )
debug_message ( "CXXFLAGS_${_SUFFIX}: ${CXXFLAGS_${_SUFFIX}}" )
endmacro ( )
function ( vcpkg_configure_make )
2020-12-02 05:37:26 +08:00
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
2020-11-11 01:52:02 +08:00
cmake_parse_arguments ( PARSE_ARGV 0 _csc
" A U T O C O N F I G ; S K I P _ C O N F I G U R E ; C O P Y _ S O U R C E ; D I S A B L E _ V E R B O S E _ F L A G S ; N O _ A D D I T I O N A L _ P A T H S ; A D D _ B I N _ T O _ P A T H ; U S E _ W R A P P E R S ; D E T E R M I N E _ B U I L D _ T R I P L E T "
" S O U R C E _ P A T H ; P R O J E C T _ S U B P A T H ; P R E R U N _ S H E L L ; B U I L D _ T R I P L E T "
2020-11-18 01:18:59 +08:00
" O P T I O N S ; O P T I O N S _ D E B U G ; O P T I O N S _ R E L E A S E ; C O N F I G U R E _ E N V I R O N M E N T _ V A R I A B L E S ; C O N F I G _ D E P E N D E N T _ E N V I R O N M E N T ; A D D I T I O N A L _ M S Y S _ P A C K A G E S "
2020-11-11 01:52:02 +08:00
)
vcpkg_internal_get_cmake_vars ( OUTPUT_FILE _VCPKG_CMAKE_VARS_FILE )
set ( _VCPKG_CMAKE_VARS_FILE "${_VCPKG_CMAKE_VARS_FILE}" PARENT_SCOPE )
debug_message ( "Including cmake vars from: ${_VCPKG_CMAKE_VARS_FILE}" )
include ( "${_VCPKG_CMAKE_VARS_FILE}" )
if ( DEFINED VCPKG_MAKE_BUILD_TRIPLET )
set ( _csc_BUILD_TRIPLET ${ VCPKG_MAKE_BUILD_TRIPLET } ) # Triplet overwrite for crosscompiling
endif ( )
set ( SRC_DIR "${_csc_SOURCE_PATH}/${_csc_PROJECT_SUBPATH}" )
set ( REQUIRES_AUTOGEN FALSE ) # use autogen.sh
set ( REQUIRES_AUTOCONFIG FALSE ) # use autotools and configure.ac
if ( EXISTS "${SRC_DIR}/configure" AND "${SRC_DIR}/configure.ac" ) # remove configure; rerun autoconf
if ( NOT VCPKG_MAINTAINER_SKIP_AUTOCONFIG ) # If fixing bugs skipping autoconfig saves a lot of time
set ( REQUIRES_AUTOCONFIG TRUE )
file ( REMOVE "${SRC_DIR}/configure" ) # remove possible autodated configure scripts
set ( _csc_AUTOCONFIG ON )
endif ( )
elseif ( EXISTS "${SRC_DIR}/configure" AND NOT _csc_SKIP_CONFIGURE ) # run normally; no autoconf or autgen required
elseif ( EXISTS "${SRC_DIR}/configure.ac" ) # Run autoconfig
set ( REQUIRES_AUTOCONFIG TRUE )
set ( _csc_AUTOCONFIG ON )
elseif ( EXISTS "${SRC_DIR}/autogen.sh" ) # Run autogen
set ( REQUIRES_AUTOGEN TRUE )
else ( )
message ( FATAL_ERROR "Could not determine method to configure make" )
endif ( )
debug_message ( "REQUIRES_AUTOGEN:${REQUIRES_AUTOGEN}" )
debug_message ( "REQUIRES_AUTOCONFIG:${REQUIRES_AUTOCONFIG}" )
2021-05-27 04:48:41 +08:00
if ( CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe" ) #only applies to windows (clang-)cl and lib
if ( _csc_AUTOCONFIG )
set ( _csc_USE_WRAPPERS TRUE )
else ( )
# Keep the setting from portfiles.
# Without autotools we assume a custom configure script which correctly handles cl and lib.
# Otherwise the port needs to set CC|CXX|AR and probably CPP.
endif ( )
else ( )
set ( _csc_USE_WRAPPERS FALSE )
endif ( )
2020-11-11 01:52:02 +08:00
# Backup environment variables
# CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJCXX R UPC Y
set ( _cm_FLAGS AS CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC )
list ( TRANSFORM _cm_FLAGS APPEND "FLAGS" )
_vcpkg_backup_env_variables ( ${ _cm_FLAGS } )
# FC fotran compiler | FF Fortran 77 compiler
# LDFLAGS -> pass -L flags
# LIBS -> pass -l flags
#Used by gcc/linux
_vcpkg_backup_env_variables ( C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH )
#Used by cl
_vcpkg_backup_env_variables ( INCLUDE LIB LIBPATH )
set ( _vcm_paths_with_spaces FALSE )
if ( CURRENT_PACKAGES_DIR MATCHES " " OR CURRENT_INSTALLED_DIR MATCHES " " )
# Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)!
message ( WARNING "Detected whitespace in root directory. Please move the path to one without whitespaces! The required tools do not handle whitespaces correctly and the build will most likely fail" )
set ( _vcm_paths_with_spaces TRUE )
endif ( )
# Pre-processing windows configure requirements
2021-05-01 02:26:05 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
if ( CMAKE_HOST_WIN32 )
list ( APPEND MSYS_REQUIRE_PACKAGES binutils libtool autoconf automake-wrapper automake1.16 m4 )
vcpkg_acquire_msys ( MSYS_ROOT PACKAGES ${ MSYS_REQUIRE_PACKAGES } ${ _csc_ADDITIONAL_MSYS_PACKAGES } )
endif ( )
if ( _csc_AUTOCONFIG AND NOT _csc_BUILD_TRIPLET OR _csc_DETERMINE_BUILD_TRIPLET OR VCPKG_CROSSCOMPILING AND NOT _csc_BUILD_TRIPLET )
2020-11-11 01:52:02 +08:00
_vcpkg_determine_autotools_host_cpu ( BUILD_ARCH ) # VCPKG_HOST => machine you are building on => --build=
_vcpkg_determine_autotools_target_cpu ( TARGET_ARCH )
# --build: the machine you are building on
# --host: the machine you are building for
# --target: the machine that CC will produce binaries for
# https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler
# Only for ports using autotools so we can assume that they follow the common conventions for build/target/host
2021-05-01 02:26:05 +08:00
if ( CMAKE_HOST_WIN32 )
set ( _csc_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-mingw32" ) # This is required since we are running in a msys
# shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys
endif ( )
if ( NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32 ) # we don't need to specify the additional flags if we build nativly, this does not hold when we are not on windows
2020-11-11 01:52:02 +08:00
string ( APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32" ) # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
endif ( )
if ( VCPKG_TARGET_IS_UWP AND NOT _csc_BUILD_TRIPLET MATCHES "--host" )
# Needs to be different from --build to enable cross builds.
string ( APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32" )
endif ( )
debug_message ( "Using make triplet: ${_csc_BUILD_TRIPLET}" )
endif ( )
2021-05-01 02:26:05 +08:00
if ( CMAKE_HOST_WIN32 )
set ( APPEND_ENV )
2021-05-27 04:48:41 +08:00
if ( _csc_USE_WRAPPERS )
2021-05-01 02:26:05 +08:00
set ( APPEND_ENV ";${MSYS_ROOT}/usr/share/automake-1.16" )
string ( APPEND APPEND_ENV ";${SCRIPTS}/buildsystems/make_wrapper" ) # Other required wrappers are also located there
endif ( )
# This inserts msys before system32 (which masks sort.exe and find.exe) but after MSVC (which avoids masking link.exe)
string ( REPLACE ";$ENV{SystemRoot}\\System32;" "${APPEND_ENV};${MSYS_ROOT}/usr/bin;$ENV{SystemRoot}\\System32;" NEWPATH "$ENV{PATH}" )
string ( REPLACE ";$ENV{SystemRoot}\\system32;" "${APPEND_ENV};${MSYS_ROOT}/usr/bin;$ENV{SystemRoot}\\system32;" NEWPATH "$ENV{PATH}" )
set ( ENV{PATH} "${NEWPATH}" )
set ( BASH "${MSYS_ROOT}/usr/bin/bash.exe" )
2020-11-11 01:52:02 +08:00
endif ( )
macro ( _vcpkg_append_to_configure_environment inoutstring var defaultval )
2021-05-01 02:26:05 +08:00
# Allows to overwrite settings in custom triplets via the environment on windows
if ( CMAKE_HOST_WIN32 AND DEFINED ENV{ ${ var } } )
2020-11-11 01:52:02 +08:00
string ( APPEND ${ inoutstring } " ${var}='$ENV{${var}}'" )
else ( )
string ( APPEND ${ inoutstring } " ${var}='${defaultval}'" )
endif ( )
endmacro ( )
set ( CONFIGURE_ENV "V=1" )
2021-04-08 03:41:56 +08:00
# Remove full filepaths due to spaces and prepend filepaths to PATH (cross-compiling tools are unlikely on path by default)
2020-11-11 01:52:02 +08:00
set ( progs VCPKG_DETECTED_CMAKE_C_COMPILER VCPKG_DETECTED_CMAKE_CXX_COMPILER VCPKG_DETECTED_CMAKE_AR
V C P K G _ D E T E C T E D _ C M A K E _ L I N K E R V C P K G _ D E T E C T E D _ C M A K E _ R A N L I B V C P K G _ D E T E C T E D _ C M A K E _ O B J D U M P
V C P K G _ D E T E C T E D _ C M A K E _ S T R I P V C P K G _ D E T E C T E D _ C M A K E _ N M V C P K G _ D E T E C T E D _ C M A K E _ D L L T O O L V C P K G _ D E T E C T E D _ C M A K E _ R C _ C O M P I L E R )
foreach ( prog IN LISTS progs )
if ( ${ prog } )
2021-04-08 03:41:56 +08:00
set ( path "${${prog}}" )
unset ( prog_found CACHE )
2020-11-11 01:52:02 +08:00
get_filename_component ( ${ prog } "${${prog}}" NAME )
2021-04-08 03:41:56 +08:00
find_program ( prog_found ${ ${prog } } PATHS ENV PATH NO_DEFAULT_PATH )
if ( NOT path STREQUAL prog_found )
get_filename_component ( path "${path}" DIRECTORY )
vcpkg_add_to_path ( PREPEND ${ path } )
endif ( )
2020-11-11 01:52:02 +08:00
endif ( )
endforeach ( )
2021-05-27 04:48:41 +08:00
if ( _csc_USE_WRAPPERS )
2020-11-11 01:52:02 +08:00
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CPP "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CC "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CC_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CXX "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV RC "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV WINDRES "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}" )
if ( VCPKG_DETECTED_CMAKE_AR )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}" )
else ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV AR "ar-lib lib.exe -verbose" )
endif ( )
else ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CPP "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CC "${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CC_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}" )
if ( VCPKG_DETECTED_CMAKE_AR )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV AR "${VCPKG_DETECTED_CMAKE_AR}" )
else ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV AR "lib.exe -verbose" )
endif ( )
endif ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose" )
if ( VCPKG_DETECTED_CMAKE_RANLIB )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}" ) # Trick to ignore the RANLIB call
else ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV RANLIB ":" )
endif ( )
if ( VCPKG_DETECTED_CMAKE_OBJDUMP ) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}" ) # Trick to ignore the RANLIB call
endif ( )
if ( VCPKG_DETECTED_CMAKE_STRIP ) # If required set the ENV variable STRIP in the portfile correctly
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV STRIP "${VCPKG_DETECTED_CMAKE_STRIP}" )
else ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV STRIP ":" )
list ( APPEND _csc_OPTIONS ac_cv_prog_ac_ct_STRIP=: )
endif ( )
if ( VCPKG_DETECTED_CMAKE_NM ) # If required set the ENV variable NM in the portfile correctly
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV NM "${VCPKG_DETECTED_CMAKE_NM}" )
else ( )
# Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm
# and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS)
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV NM "dumpbin.exe -symbols -headers" )
endif ( )
if ( VCPKG_DETECTED_CMAKE_DLLTOOL ) # If required set the ENV variable DLLTOOL in the portfile correctly
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}" )
else ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll" )
endif ( )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV CCAS ":" ) # If required set the ENV variable CCAS in the portfile correctly
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV AS ":" ) # If required set the ENV variable AS in the portfile correctly
foreach ( _env IN LISTS _csc_CONFIGURE_ENVIRONMENT_VARIABLES )
_vcpkg_append_to_configure_environment ( CONFIGURE_ENV ${ _env } "${${_env}}" )
endforeach ( )
debug_message ( "CONFIGURE_ENV: '${CONFIGURE_ENV}'" )
# Other maybe interesting variables to control
# COMPILE This is the command used to actually compile a C source file. The file name is appended to form the complete command line.
# LINK This is the command used to actually link a C program.
# CXXCOMPILE The command used to actually compile a C++ source file. The file name is appended to form the complete command line.
# CXXLINK The command used to actually link a C++ program.
# Variables not correctly detected by configure. In release builds.
list ( APPEND _csc_OPTIONS gl_cv_double_slash_root=yes
a c _ c v _ f u n c _ m e m m o v e = y e s )
2020-11-18 01:18:59 +08:00
#list(APPEND _csc_OPTIONS lt_cv_deplibs_check_method=pass_all) # Just ignore libtool checks
2021-01-20 11:40:30 +08:00
if ( VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]64$" )
2020-11-11 01:52:02 +08:00
list ( APPEND _csc_OPTIONS gl_cv_host_cpu_c_abi=no )
2021-01-20 11:40:30 +08:00
# Currently needed for arm64 because objdump yields: "unrecognised machine type (0xaa64) in Import Library Format archive"
list ( APPEND _csc_OPTIONS lt_cv_deplibs_check_method=pass_all )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]$" )
# Currently needed for arm because objdump yields: "unrecognised machine type (0x1c4) in Import Library Format archive"
list ( APPEND _csc_OPTIONS lt_cv_deplibs_check_method=pass_all )
2020-11-11 01:52:02 +08:00
endif ( )
2021-05-01 02:26:05 +08:00
endif ( )
if ( CMAKE_HOST_WIN32 )
#Some PATH handling for dealing with spaces....some tools will still fail with that!
string ( REPLACE " " "\\\ " _VCPKG_PREFIX ${ CURRENT_INSTALLED_DIR } )
string ( REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PREFIX "${_VCPKG_PREFIX}" )
set ( _VCPKG_INSTALLED ${ CURRENT_INSTALLED_DIR } )
set ( prefix_var "'\${prefix}'" ) # Windows needs extra quotes or else the variable gets expanded in the makefile!
2020-11-11 01:52:02 +08:00
else ( )
string ( REPLACE " " "\ " _VCPKG_PREFIX ${ CURRENT_INSTALLED_DIR } )
string ( REPLACE " " "\ " _VCPKG_INSTALLED ${ CURRENT_INSTALLED_DIR } )
set ( EXTRA_QUOTES )
set ( prefix_var "\${prefix}" )
endif ( )
2021-01-29 11:38:32 +08:00
# macOS - cross-compiling support
if ( VCPKG_TARGET_IS_OSX )
if ( _csc_AUTOCONFIG AND NOT _csc_BUILD_TRIPLET OR _csc_DETERMINE_BUILD_TRIPLET )
_vcpkg_determine_autotools_host_arch_mac ( BUILD_ARCH ) # machine you are building on => --build=
_vcpkg_determine_autotools_target_arch_mac ( TARGET_ARCH )
# --build: the machine you are building on
# --host: the machine you are building for
# --target: the machine that CC will produce binaries for
# https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler
# Only for ports using autotools so we can assume that they follow the common conventions for build/target/host
if ( NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}" ) # we don't need to specify the additional flags if we build natively.
2021-03-23 06:40:23 +08:00
set ( _csc_BUILD_TRIPLET "--host=${TARGET_ARCH}-apple-darwin" ) # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
2021-01-29 11:38:32 +08:00
endif ( )
debug_message ( "Using make triplet: ${_csc_BUILD_TRIPLET}" )
endif ( )
endif ( )
2020-11-11 01:52:02 +08:00
# Cleanup previous build dirs
file ( REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } - d b g "
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } " )
# Set configure paths
set ( _csc_OPTIONS_RELEASE ${ _csc_OPTIONS_RELEASE } "--prefix=${EXTRA_QUOTES}${_VCPKG_PREFIX}${EXTRA_QUOTES}" )
set ( _csc_OPTIONS_DEBUG ${ _csc_OPTIONS_DEBUG } "--prefix=${EXTRA_QUOTES}${_VCPKG_PREFIX}/debug${EXTRA_QUOTES}" )
if ( NOT _csc_NO_ADDITIONAL_PATHS )
set ( _csc_OPTIONS_RELEASE ${ _csc_OPTIONS_RELEASE }
# Important: These should all be relative to prefix!
" - - b i n d i r = $ { p r e f i x _ v a r } / t o o l s / $ { P O R T } / b i n "
" - - s b i n d i r = $ { p r e f i x _ v a r } / t o o l s / $ { P O R T } / s b i n "
#"--libdir='\${prefix}'/lib" # already the default!
#"--includedir='\${prefix}'/include" # already the default!
" - - m a n d i r = $ { p r e f i x _ v a r } / s h a r e / $ { P O R T } "
" - - d o c d i r = $ { p r e f i x _ v a r } / s h a r e / $ { P O R T } "
" - - d a t a r o o t d i r = $ { p r e f i x _ v a r } / s h a r e / $ { P O R T } " )
set ( _csc_OPTIONS_DEBUG ${ _csc_OPTIONS_DEBUG }
# Important: These should all be relative to prefix!
" - - b i n d i r = $ { p r e f i x _ v a r } / . . / t o o l s / $ { P O R T } / d e b u g / b i n "
" - - s b i n d i r = $ { p r e f i x _ v a r } / . . / t o o l s / $ { P O R T } / d e b u g / s b i n "
#"--libdir='\${prefix}'/lib" # already the default!
" - - i n c l u d e d i r = $ { p r e f i x _ v a r } / . . / i n c l u d e "
" - - d a t a r o o t d i r = $ { p r e f i x _ v a r } / s h a r e / $ { P O R T } " )
endif ( )
# Setup common options
if ( NOT DISABLE_VERBOSE_FLAGS )
list ( APPEND _csc_OPTIONS --disable-silent-rules --verbose )
endif ( )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
list ( APPEND _csc_OPTIONS --enable-shared --disable-static )
else ( )
list ( APPEND _csc_OPTIONS --disable-shared --enable-static )
endif ( )
2021-06-09 00:50:09 +08:00
# Can be set in the triplet to append options for configure
if ( DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS )
list ( APPEND _csc_OPTIONS ${ VCPKG_MAKE_CONFIGURE_OPTIONS } )
endif ( )
if ( DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE )
list ( APPEND _csc_OPTIONS_RELEASE ${ VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE } )
endif ( )
if ( DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG )
list ( APPEND _csc_OPTIONS_DEBUG ${ VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG } )
endif ( )
2020-11-11 01:52:02 +08:00
file ( RELATIVE_PATH RELATIVE_BUILD_PATH "${CURRENT_BUILDTREES_DIR}" "${_csc_SOURCE_PATH}/${_csc_PROJECT_SUBPATH}" )
set ( base_cmd )
if ( CMAKE_HOST_WIN32 )
set ( base_cmd ${ BASH } --noprofile --norc --debug )
2021-05-01 02:26:05 +08:00
else ( )
find_program ( base_cmd bash REQUIRED )
endif ( )
if ( VCPKG_TARGET_IS_WINDOWS )
2020-11-11 01:52:02 +08:00
list ( JOIN _csc_OPTIONS " " _csc_OPTIONS )
list ( JOIN _csc_OPTIONS_RELEASE " " _csc_OPTIONS_RELEASE )
list ( JOIN _csc_OPTIONS_DEBUG " " _csc_OPTIONS_DEBUG )
endif ( )
# Setup include environment (since these are buildtype independent restoring them is unnecessary)
2021-05-25 06:47:44 +08:00
macro ( prepend_include_path var )
if ( "${${var}_BACKUP}" STREQUAL "" )
set ( ENV{ ${ var } } "${_VCPKG_INSTALLED}/include" )
else ( )
set ( ENV{ ${ var } } "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${${var}_BACKUP}" )
endif ( )
endmacro ( )
2020-11-11 01:52:02 +08:00
# Used by CL
2021-05-25 06:47:44 +08:00
prepend_include_path ( INCLUDE )
2020-11-11 01:52:02 +08:00
# Used by GCC
2021-05-25 06:47:44 +08:00
prepend_include_path ( C_INCLUDE_PATH )
prepend_include_path ( CPLUS_INCLUDE_PATH )
2020-11-11 01:52:02 +08:00
# Flags should be set in the toolchain instead (Setting this up correctly requires a function named vcpkg_determined_cmake_compiler_flags which can also be used to setup CC and CXX etc.)
if ( VCPKG_TARGET_IS_WINDOWS )
_vcpkg_backup_env_variables ( _CL_ _LINK_ )
# TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined
if ( VCPKG_TARGET_IS_UWP )
# Be aware that configure thinks it is crosscompiling due to:
# error while loading shared libraries: VCRUNTIME140D_APP.dll:
# cannot open shared object file: No such file or directory
# IMPORTANT: The only way to pass linker flags through libtool AND the compile wrapper
# is to use the CL and LINK environment variables !!!
# (This is due to libtool and compiler wrapper using the same set of options to pass those variables around)
string ( REPLACE "\\" "/" VCToolsInstallDir "$ENV{VCToolsInstallDir}" )
# Can somebody please check if CMake's compiler flags for UWP are correct?
set ( ENV{_CL_} "$ENV{_CL_} /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\" ${ VCToolsInstallDir } /lib/x86/store/references/platform.winmd\ "" )
string ( APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE " -ZW:nostdlib" )
string ( APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG " -ZW:nostdlib" )
set ( ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES} /MANIFEST /DYNAMICBASE /WINMD:NO /APPCONTAINER" )
endif ( )
endif ( )
macro ( convert_to_list input output )
string ( REGEX MATCHALL "(( +|^ *)[^ ]+)" ${ output } "${${input}}" )
endmacro ( )
convert_to_list ( VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES C_LIBS_LIST )
convert_to_list ( VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES CXX_LIBS_LIST )
set ( ALL_LIBS_LIST ${ C_LIBS_LIST } ${ CXX_LIBS_LIST } )
list ( REMOVE_DUPLICATES ALL_LIBS_LIST )
list ( TRANSFORM ALL_LIBS_LIST STRIP )
2020-11-18 01:18:59 +08:00
#Do lib list transformation from name.lib to -lname if necessary
set ( _VCPKG_TRANSFORM_LIBS TRUE )
if ( VCPKG_TARGET_IS_UWP )
set ( _VCPKG_TRANSFORM_LIBS FALSE )
# Avoid libtool choke: "Warning: linker path does not have real file for library -lWindowsApp."
# The problem with the choke is that libtool always falls back to built a static library even if a dynamic was requested.
# Note: Env LIBPATH;LIB are on the search path for libtool by default on windows.
# It even does unix/dos-short/unix transformation with the path to get rid of spaces.
endif ( )
set ( _lprefix )
if ( _VCPKG_TRANSFORM_LIBS )
set ( _lprefix "-l" )
list ( TRANSFORM ALL_LIBS_LIST REPLACE "(.dll.lib|.lib|.a|.so)$" "" )
if ( VCPKG_TARGET_IS_WINDOWS )
list ( REMOVE_ITEM ALL_LIBS_LIST "uuid" )
endif ( )
2020-12-02 06:13:58 +08:00
list ( TRANSFORM ALL_LIBS_LIST REPLACE "^(${_lprefix})" "" )
2020-11-11 01:52:02 +08:00
endif ( )
2020-11-18 01:18:59 +08:00
list ( JOIN ALL_LIBS_LIST " ${_lprefix}" ALL_LIBS_STRING )
2021-05-27 00:13:16 +08:00
if ( VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" )
# libtool must be told explicitly that there is no dynamic linkage for uuid.
# The "-Wl,..." syntax is understood by libtool and gcc, but no by ld.
string ( REPLACE " -luuid" " -Wl,-Bstatic,-luuid,-Bdynamic" ALL_LIBS_STRING "${ALL_LIBS_STRING}" )
endif ( )
2020-11-11 01:52:02 +08:00
if ( ALL_LIBS_STRING )
2020-11-18 01:18:59 +08:00
set ( ALL_LIBS_STRING "${_lprefix}${ALL_LIBS_STRING}" )
2020-11-11 01:52:02 +08:00
if ( DEFINED ENV{LIBS} )
2020-11-18 01:18:59 +08:00
set ( ENV{LIBS} "$ENV{LIBS} ${ALL_LIBS_STRING}" )
2020-11-11 01:52:02 +08:00
else ( )
2020-11-18 01:18:59 +08:00
set ( ENV{LIBS} "${ALL_LIBS_STRING}" )
2020-11-11 01:52:02 +08:00
endif ( )
endif ( )
2021-06-04 05:56:25 +08:00
debug_message ( "ENV{LIBS}:$ENV{LIBS}" )
2020-11-11 01:52:02 +08:00
vcpkg_find_acquire_program ( PKGCONFIG )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" AND NOT PKGCONFIG STREQUAL "--static" )
set ( PKGCONFIG "${PKGCONFIG} --static" ) # Is this still required or was the PR changing the pc files accordingly merged?
endif ( )
# Run autoconf if necessary
set ( _GENERATED_CONFIGURE FALSE )
if ( _csc_AUTOCONFIG OR REQUIRES_AUTOCONFIG )
find_program ( AUTORECONF autoreconf )
if ( NOT AUTORECONF )
message ( FATAL_ERROR "${PORT} requires autoconf from the system package manager (example: \" sudo apt-get install autoconf\ ")" )
endif ( )
message ( STATUS "Generating configure for ${TARGET_TRIPLET}" )
if ( CMAKE_HOST_WIN32 )
vcpkg_execute_required_process (
C O M M A N D $ { b a s e _ c m d } - c " a u t o r e c o n f - v f i "
W O R K I N G _ D I R E C T O R Y " $ { S R C _ D I R } "
L O G N A M E a u t o c o n f - $ { T A R G E T _ T R I P L E T }
)
else ( )
vcpkg_execute_required_process (
C O M M A N D $ { A U T O R E C O N F } - v f i
W O R K I N G _ D I R E C T O R Y " $ { S R C _ D I R } "
L O G N A M E a u t o c o n f - $ { T A R G E T _ T R I P L E T }
)
endif ( )
message ( STATUS "Finished generating configure for ${TARGET_TRIPLET}" )
endif ( )
if ( REQUIRES_AUTOGEN )
message ( STATUS "Generating configure for ${TARGET_TRIPLET} via autogen.sh" )
if ( CMAKE_HOST_WIN32 )
vcpkg_execute_required_process (
C O M M A N D $ { b a s e _ c m d } - c " . / a u t o g e n . s h "
W O R K I N G _ D I R E C T O R Y " $ { S R C _ D I R } "
L O G N A M E a u t o c o n f - $ { T A R G E T _ T R I P L E T }
)
else ( )
vcpkg_execute_required_process (
C O M M A N D " . / a u t o g e n . s h "
W O R K I N G _ D I R E C T O R Y " $ { S R C _ D I R } "
L O G N A M E a u t o c o n f - $ { T A R G E T _ T R I P L E T }
)
endif ( )
message ( STATUS "Finished generating configure for ${TARGET_TRIPLET}" )
endif ( )
if ( _csc_PRERUN_SHELL )
message ( STATUS "Prerun shell with ${TARGET_TRIPLET}" )
vcpkg_execute_required_process (
C O M M A N D $ { b a s e _ c m d } - c " $ { _ c s c _ P R E R U N _ S H E L L } "
W O R K I N G _ D I R E C T O R Y " $ { S R C _ D I R } "
L O G N A M E p r e r u n - $ { T A R G E T _ T R I P L E T }
)
endif ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" AND NOT _csc_NO_DEBUG )
set ( _VAR_SUFFIX DEBUG )
set ( PATH_SUFFIX_ ${ _VAR_SUFFIX } "/debug" )
set ( SHORT_NAME_ ${ _VAR_SUFFIX } "dbg" )
list ( APPEND _buildtypes ${ _VAR_SUFFIX } )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
2021-06-04 05:56:25 +08:00
set ( LINKER_FLAGS_ ${ _VAR_SUFFIX } "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_VAR_SUFFIX}}" )
2020-11-11 01:52:02 +08:00
else ( ) # dynamic
2021-06-04 05:56:25 +08:00
set ( LINKER_FLAGS_ ${ _VAR_SUFFIX } "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${_VAR_SUFFIX}}" )
2020-11-11 01:52:02 +08:00
endif ( )
_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags ( ${ _VAR_SUFFIX } )
if ( CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe" )
if ( NOT _vcm_paths_with_spaces )
set ( LDFLAGS_ ${ _VAR_SUFFIX } "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link" )
endif ( )
if ( DEFINED ENV{_LINK_} )
set ( LINK_ENV_ ${ _VAR_SUFFIX } "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}" )
else ( )
set ( LINK_ENV_ ${ _VAR_SUFFIX } "${LINKER_FLAGS_${_VAR_SUFFIX}}" )
endif ( )
else ( )
2021-04-03 04:41:17 +08:00
set ( _link_dirs )
if ( EXISTS "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib" )
set ( _link_dirs "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib" )
endif ( )
if ( EXISTS "{_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link" )
set ( _link_dirs "${_link_dirs} -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link" )
endif ( )
string ( STRIP "${_link_dirs}" _link_dirs )
set ( LDFLAGS_ ${ _VAR_SUFFIX } "${_link_dirs} ${LINKER_FLAGS_${_VAR_SUFFIX}}" )
2020-11-11 01:52:02 +08:00
endif ( )
unset ( _VAR_SUFFIX )
endif ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release" )
set ( _VAR_SUFFIX RELEASE )
set ( PATH_SUFFIX_ ${ _VAR_SUFFIX } "" )
set ( SHORT_NAME_ ${ _VAR_SUFFIX } "rel" )
list ( APPEND _buildtypes ${ _VAR_SUFFIX } )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
2021-06-04 05:56:25 +08:00
set ( LINKER_FLAGS_ ${ _VAR_SUFFIX } "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_VAR_SUFFIX}}" )
2020-11-11 01:52:02 +08:00
else ( ) # dynamic
2021-06-04 05:56:25 +08:00
set ( LINKER_FLAGS_ ${ _VAR_SUFFIX } "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${_VAR_SUFFIX}}" )
2020-11-11 01:52:02 +08:00
endif ( )
_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags ( ${ _VAR_SUFFIX } )
if ( CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe" )
if ( NOT _vcm_paths_with_spaces )
set ( LDFLAGS_ ${ _VAR_SUFFIX } "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link" )
endif ( )
if ( DEFINED ENV{_LINK_} )
set ( LINK_ENV_ ${ _VAR_SUFFIX } "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}" )
else ( )
set ( LINK_ENV_ ${ _VAR_SUFFIX } "${LINKER_FLAGS_${_VAR_SUFFIX}}" )
endif ( )
else ( )
2021-04-03 04:41:17 +08:00
set ( _link_dirs )
if ( EXISTS "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib" )
set ( _link_dirs "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib" )
endif ( )
if ( EXISTS "{_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link" )
set ( _link_dirs "${_link_dirs} -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link" )
endif ( )
string ( STRIP "${_link_dirs}" _link_dirs )
set ( LDFLAGS_ ${ _VAR_SUFFIX } "${_link_dirs} ${LINKER_FLAGS_${_VAR_SUFFIX}}" )
2020-11-11 01:52:02 +08:00
endif ( )
unset ( _VAR_SUFFIX )
endif ( )
foreach ( _buildtype IN LISTS _buildtypes )
foreach ( ENV_VAR ${ _csc_CONFIG_DEPENDENT_ENVIRONMENT } )
if ( DEFINED ENV{ ${ ENV_VAR } } )
set ( BACKUP_CONFIG_ ${ ENV_VAR } "$ENV{${ENV_VAR}}" )
endif ( )
set ( ENV{ ${ ENV_VAR } } "${${ENV_VAR}_${_buildtype}}" )
endforeach ( )
set ( TAR_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}" )
file ( MAKE_DIRECTORY "${TAR_DIR}" )
file ( RELATIVE_PATH RELATIVE_BUILD_PATH "${TAR_DIR}" "${SRC_DIR}" )
if ( _csc_COPY_SOURCE )
file ( COPY "${SRC_DIR}/" DESTINATION "${TAR_DIR}" )
set ( RELATIVE_BUILD_PATH . )
endif ( )
# Setup PKG_CONFIG_PATH
set ( PKGCONFIG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/lib/pkgconfig" )
set ( PKGCONFIG_INSTALLED_SHARE_DIR "${CURRENT_INSTALLED_DIR}/share/pkgconfig" )
if ( ENV{PKG_CONFIG_PATH} )
set ( BACKUP_ENV_PKG_CONFIG_PATH_ ${ _buildtype } $ENV{ PKG_CONFIG_PATH } )
set ( ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_INSTALLED_SHARE_DIR}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}" )
else ( )
set ( ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_INSTALLED_SHARE_DIR}" )
endif ( )
# Setup environment
set ( ENV{CPPFLAGS} "${CPPFLAGS_${_buildtype}}" )
set ( ENV{CFLAGS} "${CFLAGS_${_buildtype}}" )
set ( ENV{CXXFLAGS} "${CXXFLAGS_${_buildtype}}" )
set ( ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${_buildtype}}" )
set ( ENV{LDFLAGS} "${LDFLAGS_${_buildtype}}" )
if ( LINK_ENV_ ${ _VAR_SUFFIX } )
set ( _LINK_CONFIG_BACKUP "$ENV{_LINK_}" )
set ( ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}" )
endif ( )
2021-06-04 05:55:50 +08:00
set ( ENV{PKG_CONFIG} "${PKGCONFIG}" )
2020-11-11 01:52:02 +08:00
2021-04-03 04:41:17 +08:00
set ( _lib_env_vars LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH )
foreach ( _lib_env_var IN LISTS _lib_env_vars )
set ( _link_path )
if ( EXISTS "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib" )
set ( _link_path "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib" )
endif ( )
if ( EXISTS "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/manual-link" )
if ( _link_path )
set ( _link_path "${_link_path}${VCPKG_HOST_PATH_SEPARATOR}" )
endif ( )
set ( _link_path "${_link_path}${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/manual-link" )
endif ( )
set ( ENV{ ${ _lib_env_var } } "${_link_path}${${_lib_env_var}_PATHLIKE_CONCAT}" )
endforeach ( )
unset ( _link_path )
unset ( _lib_env_vars )
2020-11-11 01:52:02 +08:00
2021-05-01 02:26:05 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
set ( command "${base_cmd}" -c "${CONFIGURE_ENV} ./${RELATIVE_BUILD_PATH}/configure ${_csc_BUILD_TRIPLET} ${_csc_OPTIONS} ${_csc_OPTIONS_${_buildtype}}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-05-01 02:26:05 +08:00
set ( command "${base_cmd}" "./${RELATIVE_BUILD_PATH}/configure" ${ _csc_BUILD_TRIPLET } ${ _csc_OPTIONS } ${ _csc_OPTIONS_${_buildtype } } )
2020-11-11 01:52:02 +08:00
endif ( )
2021-05-01 02:26:05 +08:00
2020-11-11 01:52:02 +08:00
if ( _csc_ADD_BIN_TO_PATH )
set ( PATH_BACKUP $ENV{ PATH } )
vcpkg_add_to_path ( "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/bin" )
endif ( )
debug_message ( "Configure command:'${command}'" )
if ( NOT _csc_SKIP_CONFIGURE )
message ( STATUS "Configuring ${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}" )
vcpkg_execute_required_process (
C O M M A N D $ { c o m m a n d }
W O R K I N G _ D I R E C T O R Y " $ { T A R _ D I R } "
L O G N A M E c o n f i g - $ { T A R G E T _ T R I P L E T } - $ { S H O R T _ N A M E _ $ { _ b u i l d t y p e } }
)
2020-12-02 06:13:58 +08:00
if ( VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
2020-11-11 01:52:02 +08:00
file ( GLOB_RECURSE LIBTOOL_FILES "${TAR_DIR}*/libtool" )
foreach ( lt_file IN LISTS LIBTOOL_FILES )
file ( READ "${lt_file}" _contents )
string ( REPLACE ".dll.lib" ".lib" _contents "${_contents}" )
file ( WRITE "${lt_file}" "${_contents}" )
endforeach ( )
endif ( )
if ( EXISTS "${TAR_DIR}/config.log" )
file ( RENAME "${TAR_DIR}/config.log" "${CURRENT_BUILDTREES_DIR}/config.log-${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}.log" )
endif ( )
endif ( )
if ( BACKUP_ENV_PKG_CONFIG_PATH_ ${ _buildtype } )
set ( ENV{PKG_CONFIG_PATH} "${BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}}" )
else ( )
unset ( ENV{PKG_CONFIG_PATH} )
endif ( )
unset ( BACKUP_ENV_PKG_CONFIG_PATH_ ${ _buildtype } )
if ( _LINK_CONFIG_BACKUP )
set ( ENV{_LINK_} "${_LINK_CONFIG_BACKUP}" )
unset ( _LINK_CONFIG_BACKUP )
endif ( )
if ( _csc_ADD_BIN_TO_PATH )
set ( ENV{PATH} "${PATH_BACKUP}" )
endif ( )
# Restore environment (config dependent)
foreach ( ENV_VAR ${ _csc_CONFIG_DEPENDENT_ENVIRONMENT } )
if ( BACKUP_CONFIG_ ${ ENV_VAR } )
set ( ENV{ ${ ENV_VAR } } "${BACKUP_CONFIG_${ENV_VAR}}" )
else ( )
unset ( ENV{ ${ ENV_VAR } } )
endif ( )
endforeach ( )
endforeach ( )
# Restore environment
_vcpkg_restore_env_variables ( ${ _cm_FLAGS } LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH )
SET ( _VCPKG_PROJECT_SOURCE_PATH ${ _csc_SOURCE_PATH } PARENT_SCOPE )
set ( _VCPKG_PROJECT_SUBPATH ${ _csc_PROJECT_SUBPATH } PARENT_SCOPE )
endfunction ( )