forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vcpkg-ci-cmake-toolchain-file] Validate toolchain file (microsoft#43527
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
scripts/test_ports/vcpkg-ci-cmake-toolchain-file/portfile.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${CURRENT_PORT_DIR}/project" | ||
DISABLE_PARALLEL_CONFIGURE # keep separate logs | ||
) | ||
vcpkg_cmake_build() |
42 changes: 42 additions & 0 deletions
42
scripts/test_ports/vcpkg-ci-cmake-toolchain-file/project/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
cmake_minimum_required(VERSION 3.30) | ||
project(cmake-toolchain-file-test C CXX) | ||
|
||
foreach(var IN ITEMS | ||
CMAKE_SYSROOT | ||
CMAKE_FIND_ROOT_PATH | ||
CMAKE_PREFIX_PATH | ||
CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES | ||
CMAKE_SYSTEM_IGNORE_PATH | ||
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY | ||
) | ||
list(JOIN "${var}" "\n " dirs) | ||
message("" "${var}:\n ${dirs}\n") | ||
endforeach() | ||
|
||
set(CMAKE_FIND_DEBUG_MODE 1) | ||
set(link_libs "") | ||
set(implicit_link_libs "${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") | ||
list(REMOVE_ITEM implicit_link_libs ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}) | ||
foreach(lib IN LISTS implicit_link_libs) | ||
if(EXISTS "${lib}") | ||
message("" "Absolute path: ${lib}\n") | ||
else() | ||
string(MAKE_C_IDENTIFIER "${lib}" id) | ||
find_library(${id}_LIBRARY NAMES "${lib}" NO_CACHE) | ||
if(NOT ${id}_LIBRARY) | ||
find_library(${id}_LIBRARY NAMES "${lib}" PATHS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} NO_DEFAULT_PATH NO_CACHE) | ||
endif() | ||
list(APPEND link_libs "${${id}_LIBRARY}") | ||
endif() | ||
endforeach() | ||
|
||
# Pull link errors into config step set of log files | ||
try_compile(link_libs_accepted | ||
SOURCES "${CMAKE_CURRENT_LIST_DIR}/main.c" | ||
LINK_LIBRARIES ${link_libs} | ||
LOG_DESCRIPTION "Checking linking with ${link_libs}" | ||
OUTPUT_VARIABLE output | ||
) | ||
if(NOT link_libs_accepted) | ||
message(FATAL_ERROR "${output}") | ||
endif() |
7 changes: 7 additions & 0 deletions
7
scripts/test_ports/vcpkg-ci-cmake-toolchain-file/project/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
printf("Hello %s\n", "world"); | ||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
scripts/test_ports/vcpkg-ci-cmake-toolchain-file/vcpkg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "vcpkg-ci-cmake-toolchain-file", | ||
"version-string": "ci", | ||
"description": "Validate vcpkg.cmake toolchain file", | ||
"homepage": "https://github.com/microsoft/vcpkg", | ||
"license": "MIT", | ||
"dependencies": [ | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters