cmake: Visual Studio misc followup on cf9a88df
.
Fix the vcpkg root setting, which was trying to use CMAKE_PROJECT_DIR before a project is defined by switching back to CMAKE_SOURCE_DIR. Also check if the user has \vcpkg or c:\vcpkg and use those if found. Use \vcpkg if ENV{CI} is set, e.g. on Appveyor. Enable nasm for visual studio builds by using the nuget nasm2 package. In Architecture.cmake check that the vcpkg arch matches the compiler arch, and throw a fatal error otherwise. When using GLOB to find the nuget package directory, use the package name as the prefix, this is quite necessary when using multiple nuget packages. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
b3932e4e3d
commit
49ca52ba03
|
@ -275,7 +275,23 @@ if(AMD64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX))
|
|||
endif()
|
||||
|
||||
if(ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS)
|
||||
if(MSVC)
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
|
||||
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND nuget.exe install nasm2 -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/nasm2*)
|
||||
|
||||
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools)
|
||||
endif()
|
||||
|
||||
enable_language(ASM_NASM)
|
||||
|
||||
set(ASM_ENABLED ON)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -14,13 +14,19 @@ endif()
|
|||
# and set WINARCH for windows stuff
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|i[3-9]86|[aA][mM][dD]64")
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 4) # 32 bit
|
||||
if(NOT (MSVC AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg))
|
||||
set(ASM_DEFAULT ON)
|
||||
endif()
|
||||
set(ASM_DEFAULT ON)
|
||||
set(X86_32 ON)
|
||||
set(WINARCH x86)
|
||||
|
||||
if(DEFINED VCPKG_TARGET_TRIPLET AND (NOT VCPKG_TARGET_TRIPLET MATCHES "^x86-"))
|
||||
message(FATAL_ERROR "ERROR: Wrong build environment architecture for VCPKG_TARGET_TRIPLET")
|
||||
endif()
|
||||
else()
|
||||
set(AMD64 ON)
|
||||
set(WINARCH x64)
|
||||
|
||||
if(DEFINED VCPKG_TARGET_TRIPLET AND (NOT VCPKG_TARGET_TRIPLET MATCHES "^x64-"))
|
||||
message(FATAL_ERROR "ERROR: Wrong build environment architecture for VCPKG_TARGET_TRIPLET")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -6,7 +6,18 @@ endmacro()
|
|||
|
||||
if(VCPKG_TARGET_TRIPLET)
|
||||
if(NOT DEFINED ENV{VCPKG_ROOT})
|
||||
get_filename_component(VCPKG_ROOT ${CMAKE_PROJECT_DIR}/../vcpkg ABSOLUTE)
|
||||
if(WIN32)
|
||||
if(DEFINED ENV{CI} OR EXISTS /vcpkg)
|
||||
set(VCPKG_ROOT /vcpkg)
|
||||
elseif(EXISTS c:/vcpkg)
|
||||
set(VCPKG_ROOT c:/vcpkg)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VCPKG_ROOT)
|
||||
get_filename_component(VCPKG_ROOT ${CMAKE_SOURCE_DIR}/../vcpkg ABSOLUTE)
|
||||
endif()
|
||||
|
||||
set(ENV{VCPKG_ROOT} ${VCPKG_ROOT})
|
||||
else()
|
||||
set(VCPKG_ROOT $ENV{VCPKG_ROOT})
|
||||
|
|
|
@ -544,7 +544,7 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
|
|||
)
|
||||
|
||||
# find the path to the binaries in the package and add them to find path
|
||||
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/*)
|
||||
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/Gettext.Tools*)
|
||||
|
||||
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools/bin)
|
||||
|
||||
|
|
Loading…
Reference in New Issue