Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ce4c584
[vcpkg-config-cmake] Add check for unused cmake variables
May 31, 2021
cc3b3f6
continue when the contents are not found
May 31, 2021
dbb3430
Update ports/vcpkg-cmake/vcpkg_cmake_configure.cmake
JackBoosY May 31, 2021
be7307e
Update scripts/cmake/vcpkg_configure_cmake.cmake
JackBoosY May 31, 2021
13f2fca
Improve logical
Jun 1, 2021
0e80fea
add option OPTIONS_CHECK_SKIP to vcpkg_cmake_configure and vcpkg_conf…
Jun 1, 2021
3c3ba18
Update docs
Jun 1, 2021
ca20f55
Improve the warning message output
Jun 1, 2021
bcfdc0f
update warning message.
Jun 3, 2021
2464a3e
Make Nicole's changes to vcpkg_cmake_configure
strega-nil Jun 3, 2021
209dffc
remove regexness
strega-nil Jun 3, 2021
2bb22fb
nicole CRs
strega-nil Jun 3, 2021
82472e8
Update docs
Jun 4, 2021
63616c6
Update ports/vcpkg-cmake/vcpkg.json
JackBoosY Jun 9, 2021
fdce668
Merge branch 'master' into dev/jack/check-cmake-ununsed-vars
JackBoosY Jun 9, 2021
40faf9e
Update versions/v-/vcpkg-cmake.json
JackBoosY Jun 15, 2021
02b8226
Update scripts/cmake/vcpkg_configure_cmake.cmake
JackBoosY Jun 22, 2021
9cf00d5
Nicole's CR
strega-nil-ms Jun 30, 2021
d2962ca
Update docs
Jul 1, 2021
f256a83
Update versions/v-/vcpkg-cmake.json
JackBoosY Jul 2, 2021
0b0cd52
Update versions/v-/vcpkg-cmake.json
JackBoosY Jul 2, 2021
66fcd57
Merge branch 'master' into dev/jack/check-cmake-ununsed-vars
JackBoosY Jul 2, 2021
2ab78a5
Update versions/v-/vcpkg-cmake.json
JackBoosY Jul 2, 2021
966d74c
update port version
Jul 5, 2021
5788f05
version stuff
Jul 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/vcpkg-cmake/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vcpkg-cmake",
"version-date": "2021-02-28",
"port-version": 2
"port-version": 3
Comment thread
JackBoosY marked this conversation as resolved.
Outdated
}
37 changes: 34 additions & 3 deletions ports/vcpkg-cmake/vcpkg_cmake_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function(vcpkg_cmake_configure)
message(FATAL_ERROR "SOURCE_PATH must be set")
endif()
if(NOT DEFINED arg_LOGFILE_BASE)
set(arg_LOGFILE_BASE "config")
set(arg_LOGFILE_BASE "config-${TARGET_TRIPLET}")
endif()

if(CMAKE_HOST_WIN32)
Expand Down Expand Up @@ -351,8 +351,10 @@ function(vcpkg_cmake_configure)
vcpkg_execute_required_process(
COMMAND ninja -v
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure"
LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}"
LOGNAME "${arg_LOGFILE_BASE}"
)
list(APPEND CONFIG_LOGS ${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-out.log
Comment thread
strega-nil-ms marked this conversation as resolved.
Outdated
${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-err.log)
else()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
Expand All @@ -366,8 +368,10 @@ function(vcpkg_cmake_configure)
"-DCMAKE_BUILD_TYPE=Debug"
"-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug"
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}-dbg"
LOGNAME "${arg_LOGFILE_BASE}-dbg"
)
list(APPEND CONFIG_LOGS ${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-dbg-out.log
${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-dbg-err.log)
endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
Expand All @@ -384,8 +388,35 @@ function(vcpkg_cmake_configure)
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
LOGNAME "${arg_LOGFILE_BASE}-rel"
)
list(APPEND CONFIG_LOGS ${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-rel-out.log
${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-rel-err.log)
endif()
endif()

# Check unused variables
list(APPEND KNOWN_UNUSED_VARS CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR _VCPKG_ROOT_DIR BUILD_SHARED_LIBS VCPKG_TARGET_ARCHITECTURE)
foreach(config_log ${CONFIG_LOGS})
if (EXISTS ${config_log})
file(READ "${config_log}" CFG_LOG)
if (CFG_LOG)
debug_message("READING ${config_log}...")
string(REGEX MATCH "Manually-specified variables were not used by the project:\n([^\[]+)-- Build files have been written to" UNUSED_VARS ${CFG_LOG})
if (NOT UNUSED_VARS)
continue()
endif()
string(REPLACE "Manually-specified variables were not used by the project:\n\n" "" UNUSED_VARS ${UNUSED_VARS})
string(REPLACE "-- Build files have been written to" "" UNUSED_VARS ${UNUSED_VARS})
debug_message("Found unused variables:\n${UNUSED_VARS}")
foreach(known_macro ${KNOWN_UNUSED_VARS})
string(REPLACE " ${known_macro}\n" "" UNUSED_VARS ${UNUSED_VARS})
endforeach()
string(REPLACE "\n" "" UNUSED_VARS ${UNUSED_VARS})
if (UNUSED_VARS)
message(FATAL_ERROR "The following variables are not used in portfile.cmake, please check and remove them:\n${UNUSED_VARS}")
Comment thread
JackBoosY marked this conversation as resolved.
Outdated
endif()
endif()
endif()
endforeach()

set(Z_VCPKG_CMAKE_GENERATOR "${generator}" CACHE INTERNAL "The generator which was used to configure CMake.")
endfunction()
29 changes: 29 additions & 0 deletions scripts/cmake/vcpkg_configure_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ function(vcpkg_configure_cmake)
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure
LOGNAME ${arg_LOGNAME}
)

list(APPEND CONFIG_LOGS ${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-out.log ${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-err.log)
else()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
Expand All @@ -334,6 +336,7 @@ function(vcpkg_configure_cmake)
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME ${arg_LOGNAME}-dbg
)
list(APPEND CONFIG_LOGS ${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-dbg-out.log ${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-dbg-err.log)
endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
Expand All @@ -344,8 +347,34 @@ function(vcpkg_configure_cmake)
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME ${arg_LOGNAME}-rel
)
list(APPEND CONFIG_LOGS ${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-rel-out.log ${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-rel-err.log)
endif()
endif()

# Check unused variables
list(APPEND KNOWN_UNUSED_VARS CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR _VCPKG_ROOT_DIR BUILD_SHARED_LIBS VCPKG_TARGET_ARCHITECTURE)
foreach(config_log ${CONFIG_LOGS})
Comment thread
strega-nil-ms marked this conversation as resolved.
Outdated
if (EXISTS ${config_log})
file(READ "${config_log}" CFG_LOG)
if (CFG_LOG)
debug_message("READING ${config_log}...")
string(REGEX MATCH "Manually-specified variables were not used by the project:\n([^\[]+)-- Build files have been written to" UNUSED_VARS ${CFG_LOG})
if (NOT UNUSED_VARS)
continue()
endif()
string(REPLACE "Manually-specified variables were not used by the project:\n\n" "" UNUSED_VARS ${UNUSED_VARS})
string(REPLACE "-- Build files have been written to" "" UNUSED_VARS ${UNUSED_VARS})
debug_message("Found unused variables:\n${UNUSED_VARS}")
foreach(known_macro ${KNOWN_UNUSED_VARS})
string(REPLACE " ${known_macro}\n" "" UNUSED_VARS ${UNUSED_VARS})
endforeach()
string(REPLACE "\n" "" UNUSED_VARS ${UNUSED_VARS})
if (UNUSED_VARS)
message(FATAL_ERROR "The following variables are not used in portfile.cmake, please check and remove them:\n${UNUSED_VARS}")
Comment thread
JackBoosY marked this conversation as resolved.
Outdated
endif()
endif()
endif()
endforeach()

set(Z_VCPKG_CMAKE_GENERATOR "${GENERATOR}" PARENT_SCOPE)
endfunction()