CMake issueshttps://gitlab.kitware.com/cmake/cmake/-/issues2019-01-08T12:50:32-05:00https://gitlab.kitware.com/cmake/cmake/-/issues/18750Don't make set remove a variable2019-01-08T12:50:32-05:00Alexander GrundDon't make set remove a variableIt occured during the discussion of !2748 that it is rather surprising that `set(var)` unsets a variable.
Consider:
```
function(foo res)
set(bar "")
set(${res} ${bar} PARENT_SCOPE)
endfunction()
set(myVar "default")
foo(...It occured during the discussion of !2748 that it is rather surprising that `set(var)` unsets a variable.
Consider:
```
function(foo res)
set(bar "")
set(${res} ${bar} PARENT_SCOPE)
endfunction()
set(myVar "default")
foo(myVar)
if(myVar) # OR if(myVar STREQUAL "") OR if(myVar STREQUAL "something")
do something
endif()
```
This code looks fine as the result variable is set and checked with the "easy" and short way as `if` specifically allows using a variable.
However this contains a subtle bug as the `set` in `foo` *removes* the variable from the scope. This might even mean, a cache variable now comes into scope. Both scenarios are most likely not intended and lead to a lot of confusion or disaster.
I therefore propose to create a new policy under which `set(var)` is equivalent to `set(var "")` and hence `set` does never work as `unset`.
I do not think this will break much existing code as `if(myVar)` will now work where it didn't before so was most likely not used and only case where this is noticeable would be `if(NOT DEFINED myVar)` which I doubt many use over e.g. `if("${myVar}" STREQUAL "")` in this cases.
Note: The docs *do* mention this but only in an added sentence which I missed several times until I specifically searched for it:
> Zero arguments will cause normal variables to be unset. See the unset() command to unset variables explicitly.
This implies that for `set(...CACHE...)` it will set an empty cache variable(?) which again is unexpected. Again the proposed behaviour is more clear and predictable.
At the very least the docs should make a strongly visible hint out of that sentence.https://gitlab.kitware.com/cmake/cmake/-/issues/18768Support more globbing in search paths for `find_X` commands2019-01-08T11:10:05-05:00Ben BoeckelSupport more globbing in search paths for `find_X` commandsCurrently, limited globbing is supported. This is restricted to `PATHS` arguments and only if they contain `/*`, therefore globbing the entire contents of a directory.
Cc: @brad.king @chuck.atkinsCurrently, limited globbing is supported. This is restricted to `PATHS` arguments and only if they contain `/*`, therefore globbing the entire contents of a directory.
Cc: @brad.king @chuck.atkinshttps://gitlab.kitware.com/cmake/cmake/-/issues/18718FindFLEX: support target_include_directories2019-01-08T08:46:37-05:00Joachim WuttkeFindFLEX: support target_include_directoriesThe Help page on FindFLEX describes usage with `include_directories`, which in general ought to be replaced by `target_include_directories`.
If this renovation is possible with the current FindFLEX, then of course this is merely a docum...The Help page on FindFLEX describes usage with `include_directories`, which in general ought to be replaced by `target_include_directories`.
If this renovation is possible with the current FindFLEX, then of course this is merely a documentation issue.https://gitlab.kitware.com/cmake/cmake/-/issues/18766FindPerl.cmake from git bash finds an incompatible perl2019-01-08T07:05:16-05:00Peter Wupeter@lekensteyn.nlFindPerl.cmake from git bash finds an incompatible perlOn Windows, there is typically no Perl distribution installed. One can install Cygwin Perl, Strawberry Perl, ActiveState Perl and probably others. Consider the following CMakeLists.txt file:
```cmake
cmake_minimum_required(VERSION 3.12)...On Windows, there is typically no Perl distribution installed. One can install Cygwin Perl, Strawberry Perl, ActiveState Perl and probably others. Consider the following CMakeLists.txt file:
```cmake
cmake_minimum_required(VERSION 3.12)
project(FindPerlTest LANGUAGES)
find_package(Perl REQUIRED)
message(STATUS "PERL_FOUND: ${PERL_FOUND}")
message(STATUS "PERL_EXECUTABLE: ${PERL_EXECUTABLE}")
message(STATUS "PERL_VERSION_STRING: ${PERL_VERSION_STRING}")
```
When executed from CMD or PowerShell, it properly locates Strawberry Perl (if using CMake 3.12 or newer). When executed from git-bash however, it finds an incompatible version at `C:/Program Files/Git/usr/bin/perl.exe`. This version is rather limited and lacks modules such as `Pod::Usage`. (The current Windows preview of Travis CI executes all commands from git bash, so this can potentially have increasingly more impact.)
As a project, we have some potential workarounds:
- Set `CMAKE_PROGRAM_PATH` to `C:/Strawberry/perl/bin`.
- Copy FindPerl.cmake and change `PATHS` to `HINTS` in `find_path(PERL_EXECUTABLE NAMES perl PATHS ...)` such that some educated guesses can yield a result before `$ENV{PATH}`.
However I believe that changing the search behavior could be beneficial for other consumers of Perl on Windows. What do you think about one of these:
- ~~Search for pod2man first and use its directory as hint for finding perl.~~ Scratch this, git also includes this.
- Change PATHS to HINTS.
- (something else to the effect of ignoring git-bash Perl)https://gitlab.kitware.com/cmake/cmake/-/issues/18755CMAKE_CONFIGURE_DEPENDS cannot depend on files that don't exist in time of ge...2019-01-07T04:28:41-05:00Janusz JankowskiCMAKE_CONFIGURE_DEPENDS cannot depend on files that don't exist in time of generation stepLet's say I have optional configuration kernel-like file that I want to cause regeneration with this statement:
`set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_BINARY_DIR}/.config)`
If file already exists every...Let's say I have optional configuration kernel-like file that I want to cause regeneration with this statement:
`set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_BINARY_DIR}/.config)`
If file already exists everything works as expected -> when i change .config cmake is reconfigured.
However when file doesn't exist (when cmake is run first time) and I add/modify it then cmake is not reconfigured.
Basically the file is not added to variable CMAKE_MAKEFILE_DEPENDS in generated CMakeFiles/Makefile.cmake if it doesn't exist.
Any chance to make it work (without workarounds like dependency on directory or some fake files)?https://gitlab.kitware.com/cmake/cmake/-/issues/18720CMake "CodeBlocks - Ninja" -v option2019-01-07T02:23:44-05:00GFeichtCMake "CodeBlocks - Ninja" -v optionI'm using CMake to create a "CodeBlocks - Ninja" project.
It works but in the CodeBlocks Build options the ninja-call always has the "-v" parameter.
Does anybody know how to bring CMake not to add the "-v" option to the ninja call?
I tri...I'm using CMake to create a "CodeBlocks - Ninja" project.
It works but in the CodeBlocks Build options the ninja-call always has the "-v" parameter.
Does anybody know how to bring CMake not to add the "-v" option to the ninja call?
I tried something like "-DCMAKE_VERBOSE_MAKEFILE=OFF", but it did not help...https://gitlab.kitware.com/cmake/cmake/-/issues/18744CMake fails to evaluate nested generator expressions in ExternalProject_Add(B...2019-01-06T21:24:59-05:00David Hunt-MateoCMake fails to evaluate nested generator expressions in ExternalProject_Add(Boost)I'm trying to build Boost as an external project using the following CMakeLists.txt. I'm considering using the PLATFORM_ID generator expression to enable different build parameters depending on the target platform.
EDIT: I should note ...I'm trying to build Boost as an external project using the following CMakeLists.txt. I'm considering using the PLATFORM_ID generator expression to enable different build parameters depending on the target platform.
EDIT: I should note that I'm not confident my current Android parameters will work, but I'm focusing on the Generator Expression at the moment. If I can get the generator expression working, I could also consider compiling Boost on Windows - something like ``CONFIGURE_COMMAND $<$<PLATFORM_ID:Windows>:<SOURCE_DIR>/bootstrap.bat ...>``
```
cmake_minimum_required(VERSION 3.13)
include(ExternalProject)
set(installDir ${CMAKE_CURRENT_BINARY_DIR}/install)
set(BOOST_BUILD_DIR <SOURCE_DIR>/../boost-build)
ExternalProject_Add(boost
URL https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2
URL_HASH SHA256=7f6130bc3cf65f56a618888ce9d5ea704fa10b462be126ad053e80e553d6d8b7
INSTALL_DIR ${installDir}
BUILD_IN_SOURCE TRUE
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E time <SOURCE_DIR>/bootstrap.sh --with-libraries=filesystem,program_options,regex
COMMAND ${CMAKE_COMMAND} -E make_directory ${BOOST_BUILD_DIR}
BUILD_COMMAND $<$<PLATFORM_ID:Linux>:${CMAKE_COMMAND} -E time <SOURCE_DIR>/b2 --prefix=<INSTALL_DIR> --build-dir=${BOOST_BUILD_DIR} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} variant=release link=static cxxflags=-fPIC cxxstd=14 install>
COMMAND $<$<PLATFORM_ID:Android>:${CMAKE_COMMAND} -E time <SOURCE_DIR>/b2 --without-python --abbreviate-paths -d2 --debug-configuration --prefix=<INSTALL_DIR> --build-dir=${BOOST_BUILD_DIR} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} architecture=arm address-model=32 binary-format=elf abi=aapcs target-os=android variant=release link=static cxxflags=-fPIC cxxstd=14 install>
INSTALL_COMMAND ""
)
```
Unfortunately, when I get to the build step, I receive the following error:
```
[ 75%] Performing build step for 'boost'
/bin/sh: 1: $<1:/opt/cmake-3.13.1-Linux-x86_64/bin/cmake: not found
CMakeFiles/boost.dir/build.make:114: recipe for target 'boost-prefix/src/boost-stamp/boost-build' failed
make[2]: *** [boost-prefix/src/boost-stamp/boost-build] Error 127
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/boost.dir/all' failed
make[1]: *** [CMakeFiles/boost.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
```
As a workaround, I intend to use variables and an if/elseif/else to achieve the intended effect, but I was wondering why this generator expression failed.https://gitlab.kitware.com/cmake/cmake/-/issues/18764CUDA_ADD_CUDA_INCLUDE_ONCE does not include directories as system headers2019-01-05T16:25:16-05:00SunBlackCUDA_ADD_CUDA_INCLUDE_ONCE does not include directories as system headersWe have currently trouble with treating warnings as errors via `set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")` in your project, because `CUDA_ADD_CUDA_INCLUDE_ONCE` is adding include directories via `include_directories...We have currently trouble with treating warnings as errors via `set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")` in your project, because `CUDA_ADD_CUDA_INCLUDE_ONCE` is adding include directories via `include_directories(${CUDA_INCLUDE_DIRS})`.
Possible solution:
* Variant 1: Change line to `include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})`
* Variant 2: Use `target_include_directories(${cuda_target} SYSTEM PUBLIC ${CUDA_INCLUDE_DIRS})` (more clean).
* Variant 1+/2+: Add option to `CUDA_ADD_LIBRARY` `CUDA_ADD_EXECUTABLE`, so every developer can decide if this should be system include directories or not (in case you think there is a reason to not include it as system include directories).
Not sure if this issue is also related to `enable_language(CUDA)`.
I tried to workaround this for older CMake versions (before 3.9), but failed (see [here](https://github.com/PointCloudLibrary/pcl/issues/2745#issuecomment-451648716)). Any idea how to workaround this issue for older CMake versions?https://gitlab.kitware.com/cmake/cmake/-/issues/18761compile cmake-source to debian deb packages2019-01-04T15:43:36-05:00user706compile cmake-source to debian deb packagesHi,
I would like to always install the newest CMake on my *Debian* or *Ubuntu* PC.
Looking here...
https://cmake.org/download/#latest
... I only see a download for `tar.gz`.
But I want a deb package: that I can easily ins...Hi,
I would like to always install the newest CMake on my *Debian* or *Ubuntu* PC.
Looking here...
https://cmake.org/download/#latest
... I only see a download for `tar.gz`.
But I want a deb package: that I can easily install and (important!) **cleanly uninstall**.
So I guess I'm asking: would it be possible to provide a deb on the download-page as well?
I've written a script to create a deb from the source-code:
<details>
<summary><b>click-me</b> to fold-out section and show <b>script</b> to compile source and generate deb (<tt>get_deb_with_bootstrap.sh</tt>)</summary>
```bash
#!/usr/bin/env bash
set -eE
GIT_REPO_URL=https://gitlab.kitware.com/cmake/cmake.git
CPACK_SET_DESTDIR=0
CPACK_GENERATOR="DEB"
SCRIPT_PATH="$(readlink -e "$BASH_SOURCE")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
NUMJOBS="$(grep -c ^processor /proc/cpuinfo)"
if ls -1d ~/Qt*/[0-9]*/gcc_64 &>/dev/null; then
# Qt is installed in e.g. ~/Qt5.11.1/5.11.1/gcc_64/
Qt_in_home_dir="$(readlink -e "$(ls -1d ~/Qt* | sort -V | tail -1)"/[0-9]*/gcc_64 )"
export CMAKE_PREFIX_PATH="$Qt_in_home_dir"
export LD_LIBRARY_PATH="$Qt_in_home_dir/lib:$LD_LIBRARY_PATH"
fi
tags="$(git ls-remote --tags $GIT_REPO_URL | awk '{print $2}' | sed -E 's|^refs/tags/(.*)$|\1|g' | grep -v '\^{}$')"
# ~~~~~~~~~~ -> does not end with ^{}
version_tags="$(echo "$tags" | grep -v '[-]rc[0-9]*$')"
# ~~~~~~~~~~~~~~~~ -> does not end with -rc1 etc.
latest_version_tag="$(echo "$version_tags" | sort -V | tail -1 )"
echo $latest_version_tag
cd $SCRIPT_DIR
rm -rf cmake
git clone -b $latest_version_tag --depth 1 --recurse-submodules $GIT_REPO_URL cmake
cd $SCRIPT_DIR/cmake
BOOTSTRAP_PARALLEL="--parallel=$NUMJOBS"
BUILD_DATE="$(LC_ALL=C date -u "+%B %d, %Y")"
rm -rf Build && mkdir -p Build && cd Build
echo 'set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip rpath" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_USE_RELATIVE_PATHS ON CACHE BOOL "Use relative paths" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Verbose build" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)' >> build-flags.cmake
# see https://salsa.debian.org/cmake-team/cmake/tree/master/debian
#echo 'set(CMAKE_C_FLAGS "-g -O2 -fdebug-prefix-map=/home/albert/projects/cmake_deb/debian/cmake=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2" CACHE STRING "C flags" FORCE)' >> build-flags.cmake
#echo 'set(CMAKE_CXX_FLAGS "-g -O2 -fdebug-prefix-map=/home/albert/projects/cmake_deb/debian/cmake=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2" CACHE STRING "C++ flags" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_SKIP_BOOTSTRAP_TEST ON CACHE BOOL "Skip BootstrapTest" FORCE)' >> build-flags.cmake
echo 'set(BUILD_CursesDialog ON CACHE BOOL "Build curses GUI" FORCE)' >> build-flags.cmake
echo 'set(BUILD_QtDialog ON CACHE BOOL "Build Qt GUI" FORCE)' >> build-flags.cmake
if [[ -n "$Qt_in_home_dir" ]]; then
echo "set(CMAKE_PREFIX_PATH $CMAKE_PREFIX_PATH CACHE STRING \"\" FORCE)" >> build-flags.cmake
fi
echo 'set(CPACK_GENERATOR DEB CACHE STRING "" FORCE)' >> build-flags.cmake
echo 'set(CPACK_DEB_COMPONENT_INSTALL ON CACHE BOOL "" FORCE)' >> build-flags.cmake
echo 'set(CMake_INSTALL_COMPONENTS ON CACHE BOOL "" FORCE)' >> build-flags.cmake
echo 'set(CPACK_BINARY_DEB ON CACHE BOOL "" FORCE)' >> build-flags.cmake
../bootstrap --prefix=/usr --docdir=/share/doc/cmake --mandir=/share/man \
--init=build-flags.cmake `#--system-libs` \
--sphinx-man --sphinx-html --sphinx-flags="-D today=\"$BUILD_DATE\"" \
$BOOTSTRAP_PARALLEL --verbose -- -DCMAKE_BUILD_TYPE=Release
make -j$NUMJOBS
make package
```
</details>
.
The script above will clone into a folder `cmake`, create a build-directory `cmake/Build`
and end up with this deb-file `cmake/Build/cmake-3.13.2-Linux-x86_64.deb`.
I tried hard to get multiple debs here (via `CMake_OPTIONAL_COMPONENT`):
```
cmake-developer-reference-html
cmake-developer-reference-qthelp
sphinx-info
sphinx-man
sphinx-html
sphinx-singlehtml
sphinx-qthelp
ccmake
```
But it does not work. I only get the single deb mentioned above (`cmake/Build/cmake-3.13.2-Linux-x86_64.deb`).
Why? (Note that I am setting `set(CPACK_DEB_COMPONENT_INSTALL ON)`)
Thanks.https://gitlab.kitware.com/cmake/cmake/-/issues/18760"Detecting C compiler ABI info - failed" for MSVC when cmake starts from a ne...2019-01-04T14:28:05-05:00Олег Мирочник"Detecting C compiler ABI info - failed" for MSVC when cmake starts from a network shareWith the patch:
--- a/share/cmake-3.12/Modules/CMakeDetermineCompilerABI.cmake
+++ b/share/cmake-3.12/Modules/CMakeDetermineCompilerABI.cmake
@@ -119,7 +119,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
endif()
...With the patch:
--- a/share/cmake-3.12/Modules/CMakeDetermineCompilerABI.cmake
+++ b/share/cmake-3.12/Modules/CMakeDetermineCompilerABI.cmake
@@ -119,7 +119,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
endif()
else()
- message(STATUS "Detecting ${lang} compiler ABI info - failed")
+ message(STATUS "Detecting ${lang} compiler ABI info - failed: ${OUTPUT}; ${_copy_error}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Detecting ${lang} compiler ABI info failed to compile with the following output:\n${OUTPUT}\n${_copy_error}\n\n")
endif()
"r:/path/to/cmake/bin/cmake" reports:
-- Detecting CXX compiler ABI info - failed: Change Dir: D:/build/llvm/CMakeFiles/CMakeTmp
Run Build Command:"R:/tools/bin/gmake.exe" "cmTC_a3ba8/fast"
R:/tools/bin/gmake.exe -f CMakeFiles/cmTC_a3ba8.dir/build.make CMakeFiles/cmTC_a3ba8.dir/build
gmake[1]: Entering directory `D:/build/llvm/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_a3ba8.dir/CMakeCXXCompilerABI.cpp.obj
"c:/Program files (x86)/Microsoft Visual Studio 14.0/VC/BIN/cl.exe" /nologo /TP /GS -DINTEL_PRODUCT_RELEASE=1 -DHIDE_BUILD_STAMP=1 /MDd /Zi /Ob0 /Od /RTC1 /FoCMakeFiles/cmTC_a3ba8.dir/CMakeCXXCompilerABI.cpp.obj /FdCMakeFiles/cmTC_a3ba8.dir/ /FS -c //server/share/path/to/cmake/share/cmake-3.12/Modules/CMakeCXXCompilerABI.cpp
cl : Command line warning D9002 : ignoring unknown option '//server/share/path/to/cmake/share/cmake-3.12/Modules/CMakeCXXCompilerABI.cpp'
cl : Command line error D8003 : missing source filename
gmake[1]: *** [CMakeFiles/cmTC_a3ba8.dir/CMakeCXXCompilerABI.cpp.obj] Error 2
gmake[1]: Leaving directory `D:/build/llvm/CMakeFiles/CMakeTmp'
gmake: *** [cmTC_a3ba8/fast] Error 2
So the following patch fixes/workarounds the issue:
--- a/share/cmake-3.12/Modules/CMakeDetermineCompilerABI.cmake
+++ b/share/cmake-3.12/Modules/CMakeDetermineCompilerABI.cmake
@@ -22,10 +22,22 @@
# Avoid adding our own platform standard libraries for compilers
# from which we might detect implicit link libraries.
list(APPEND CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD_LIBRARIES=")
+ else()
+ # MSVC does not support UNC path name for source file, so:
+ # 1. Copy the source file into a local folder for compilation.
+ # 2. Use -DINCLUDE_DIRECTORIES for the source dir as the file contains '#include ".."' idioms.
+ string(REGEX MATCH "^//" UNCPATH ${src})
+ if("x${UNCPATH}" STREQUAL "x//")
+ file(COPY ${src} DESTINATION ${CMAKE_PLATFORM_INFO_DIR})
+ get_filename_component(SRCDIR ${src} DIRECTORY)
+ set(MSVC_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${SRCDIR}")
+ get_filename_component(FNAME ${src} NAME)
+ set(src "${CMAKE_PLATFORM_INFO_DIR}/${FNAME}")
+ endif()
endif()
try_compile(CMAKE_${lang}_ABI_COMPILED
${CMAKE_BINARY_DIR} ${src}
- CMAKE_FLAGS ${CMAKE_FLAGS}
+ CMAKE_FLAGS ${CMAKE_FLAGS} ${MSVC_FLAGS}
# Ignore unused flags when we are just determining the ABI.
"--no-warn-unused-cli"
OUTPUT_VARIABLE OUTPUThttps://gitlab.kitware.com/cmake/cmake/-/issues/18728Interface target link order issue2019-01-04T14:22:45-05:00Vitaliy AksyonovInterface target link order issueI use system libraries and interface targets in one project. And I found that all libraries for interface targets goes after other system libraries during linking ignoring order in target_link_libraries.
Here is a small sample which rep...I use system libraries and interface targets in one project. And I found that all libraries for interface targets goes after other system libraries during linking ignoring order in target_link_libraries.
Here is a small sample which reproduces this issue (also attached):
*CMakeLists.txt:*
```cmake
cmake_minimum_required (VERSION 3.7)
project(app)
add_library(foo INTERFACE IMPORTED)
set_target_properties(foo PROPERTIES INTERFACE_LINK_LIBRARIES liba)
add_executable(app main.cpp)
target_link_libraries(app foo libb)
```
*foo* is interface target which has `INTERFACE_LINK_LIBRARIES` property set to `liba`.
I suppose that link order shall be `liba` and then `libb` but there is the result command line:
```
/usr/bin/c++ CMakeFiles/app.dir/main.cpp.o -o app -llibb -lliba
```
Why does link order differs from expected?
PS. Don't pay attention that those libraries don't exist. It's just to show the issue.
[imp.tar.gz](/uploads/85f985906bc17c342d40d1018f6870f3/imp.tar.gz)https://gitlab.kitware.com/cmake/cmake/-/issues/18756add functionality to cmake to export dependencies of project automatically to...2019-01-04T10:47:59-05:00Carlos Gomesadd functionality to cmake to export dependencies of project automatically to a file for package managersI propose to add the functionality to cmake to export a list of dependencies in a standard format (yaml, json, toml) which can be consumed by package managers (conan, vcpkg, cget, hunter).
today we need to open the cmakelists file, chec...I propose to add the functionality to cmake to export a list of dependencies in a standard format (yaml, json, toml) which can be consumed by package managers (conan, vcpkg, cget, hunter).
today we need to open the cmakelists file, check the dependencies and use our package manager to install those dependencies...
it would be great of cmake would export a file that package managers can consume
related to https://gitlab.kitware.com/cmake/cmake/issues/17219https://gitlab.kitware.com/cmake/cmake/-/issues/18758Could CMAKE_INSTALL_RPATH_USE_LINK_PATH also add directories in the build tree?2019-01-04T10:44:07-05:00Chris RossCould CMAKE_INSTALL_RPATH_USE_LINK_PATH also add directories in the build tree?CMAKE_INSTALL_RPATH_USE_LINK_PATH does not include paths for libraries in the build tree.
Why is that?
We have a git repo for our product and we now include the current version of third party SDKs libraries in it. When we make our bun...CMAKE_INSTALL_RPATH_USE_LINK_PATH does not include paths for libraries in the build tree.
Why is that?
We have a git repo for our product and we now include the current version of third party SDKs libraries in it. When we make our bundle app we now have to explicitly add to the rpath any directories for these, whereas when they were external to the repo we did not.https://gitlab.kitware.com/cmake/cmake/-/issues/17219Feature Request: Ultimate Package Manager2019-01-04T06:50:15-05:00Brian J. DavisFeature Request: Ultimate Package ManagerDesired feature is an Ultimate Package Manager.
* Provide ability to download, build, and install a C/C++ or other project supported by package manager.
* Where FindWhatevers would be removed from standard CMake install.
* CMake ...Desired feature is an Ultimate Package Manager.
* Provide ability to download, build, and install a C/C++ or other project supported by package manager.
* Where FindWhatevers would be removed from standard CMake install.
* CMake would update with online package registry database.
* Database would utilize ExternalProject_Add and Find<Package>.
* This would allow CMake to always be up to date (well as much as that is possible) with 3rd Party package support regardless of what version of CMake is used.
* Provide pkg db local download and update. Installs could ship crusty versions if desired.
* System to provide selection of any version of 3rd party repo supported by say by repo git tag.
Here is the approaches to date
1) Try (CUDA) to support existing libs with CMake's shipped Find<PACKAGE> support which is fixed to a given installed version of CMake. The go to 3rd party apporach.
2) Alow 3rd party package maintainers to support CMake themselves. The come to CMake approach.
Here is an approach not tried to date
3) Provide an ultimate package management system using ExternalProject_Add and find_package where 3rd party package developers work with CMake/Kitware to support package management. The come together approach - [cue The Beatles here].
Have 3rd party package devs and CMake/Kitware desgin a ultimate package manager that can download build and intall any C/C++, c#, whatever ok even Fortran or COBOL if that's your bag.
Have a 3rd party package registry contatiing git/svn/cvs/hg/zip/tar URIs and version info database allowing user to select in CMake gui the packages and versions to be downloaded built and installed for release/debug/profiling
If stuck using a certain version of CMake the package manager could certainly update itself with the online package database. This way even prior (say prior DCMTK 3.6.1_20140617) versions could be fixed as any given version of CMake could pull and update of the package registry.
Certainly I cannot be the only one rolling my own. Internally it is called:
Super-E-Duper-Builder (SEDB)
and it downloads, builds, and installs any version of boost, CImg, DCMTK, VTK, ITK, VMTK (SuperBuild of SuperBuild), GLM, ZLIB, Wrangler (ok only one ver of wrangler), and some others. Some support CMake others no.https://gitlab.kitware.com/cmake/cmake/-/issues/17379Compilation error when using target_compile_definitions with cu files on VS20...2019-01-03T11:30:19-05:00Jason JuangCompilation error when using target_compile_definitions with cu files on VS2017, CUDA 9.0.I am on Windows 10, CMake 3.9.4. I recently upgraded from Visual Studio 2015, CUDA 8 to Visual Studio 2017, CUDA 9 and run into a problem that I didn't have when using VS2015 and CUDA 8.
I was following @robertmaynard post at https://de...I am on Windows 10, CMake 3.9.4. I recently upgraded from Visual Studio 2015, CUDA 8 to Visual Studio 2017, CUDA 9 and run into a problem that I didn't have when using VS2015 and CUDA 8.
I was following @robertmaynard post at https://devblogs.nvidia.com/parallelforall/building-cuda-applications-cmake/ to update my CMakeLists but here is the problem. Suppose I have the below CMakeLists
``````
cmake_minimum_required(VERSION 3.9)
project(Example LANGUAGES CXX CUDA)
if(MSVC)
set(DISABLE "__pragma(warning(push,0))")
set(ENABLE "__pragma(warning(pop))")
endif()
set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/main.cu)
add_executable(${PROJECT_NAME} ${PROJECT_SRCS})
target_compile_definitions(${PROJECT_NAME} PUBLIC
WINDOWS_DISABLE_ALL_WARNING=${DISABLE}
WINDOWS_ENABLE_ALL_WARNING=${ENABLE})
``````
and my main.cu is as simple as
``````
WINDOWS_DISABLE_ALL_WARNING
#include <vector>
WINDOWS_ENABLE_ALL_WARNING
int main(){
return 0;
}
``````
When I compile the code, I get the below error
``````
Build FAILED.
"C:\Users\jasju\Desktop\test\build\Example.sln" (default target) (1) ->
"C:\Users\jasju\Desktop\test\build\Example.vcxproj.metaproj" (default target) (2) ->
"C:\Users\jasju\Desktop\test\build\Example.vcxproj" (default target) (4) ->
"C:\Users\jasju\Desktop\test\build\Example.vcxproj" (CudaBuildCore target) (4:2) ->
(CudaBuildCore target) ->
C:/Users/jasju/Desktop/test/main.cu(9): fatal error C1001: An internal error has occurred in the compiler. [C:\Users\
jasju\Desktop\test\build\Example.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations\CUDA 9.0.t
argets(707,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe" -genc
ode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsof
t Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computi
ng Toolkit\CUDA\v9.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" --keep-dir x64\Re
lease -maxrregcount=0 --machine 64 --compile -cudart static -Xcompiler="/EHsc -Ob2" -D_WINDOWS -DNDEBUG -D"WINDOWS_
DISABLE_ALL_WARNING=__pragma(warning(push,0))" -D"WINDOWS_ENABLE_ALL_WARNING=__pragma(warning(pop))" -D"CMAKE_INTDIR=\"
Release\"" -D"WINDOWS_DISABLE_ALL_WARNING=__pragma(warning(push,0))" -D"WINDOWS_ENABLE_ALL_WARNING=__pragma(warning(pop
))" -D"CMAKE_INTDIR=\"Release\"" -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /FS /Zi /MD /GR" -o Example.dir\Release\mai
n.cu.obj "C:\Users\jasju\Desktop\test\main.cu"" exited with code 2. [C:\Users\jasju\Desktop\test\build\Example.vcxproj]
0 Warning(s)
2 Error(s)
``````
However, if I change main.cu into main.cpp, everything compiles just fine
CMakeLists
``````
cmake_minimum_required(VERSION 3.9)
project(Example)
if(MSVC)
set(DISABLE "__pragma(warning(push,0))")
set(ENABLE "__pragma(warning(pop))")
endif()
set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/main.cpp)
add_executable(${PROJECT_NAME} ${PROJECT_SRCS})
target_compile_definitions(${PROJECT_NAME} PUBLIC
WINDOWS_DISABLE_ALL_WARNING=${DISABLE}
WINDOWS_ENABLE_ALL_WARNING=${ENABLE})
``````
main.cpp
``````
WINDOWS_DISABLE_ALL_WARNING
#include <vector>
WINDOWS_ENABLE_ALL_WARNING
int main(){
return 0;
}
``````
Another thing is if I don't use `target_compile_definitions` and directly uses it like the below it also compiles
CMakeLists
``````
cmake_minimum_required(VERSION 3.9)
project(Example LANGUAGES CXX CUDA)
set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/main.cu)
add_executable(${PROJECT_NAME} ${PROJECT_SRCS})
``````
main.cu
``````
__pragma(warning(push,0))
#include <vector>
__pragma(warning(pop))
int main(){
return 0;
}
``````
But this approach is not flexible enough because I would need to have a macro to redefine for linux otherwise the pragma warning keywords will cause compilation errors in GCC.
Why is it that the combination of `target_compile_definitions` and cu files will cause the compilation error?https://gitlab.kitware.com/cmake/cmake/-/issues/18609Please document and support BUILD_STATIC_LIBS2019-01-03T06:46:13-05:00yurivictPlease document and support BUILD_STATIC_LIBSIt seems like ```BUILD_SHARED_LIBS``` is documented but ```BUILD_STATIC_LIBS``` is not.
It is important to allow to individually enable/disable static and shared libs in the projects.It seems like ```BUILD_SHARED_LIBS``` is documented but ```BUILD_STATIC_LIBS``` is not.
It is important to allow to individually enable/disable static and shared libs in the projects.https://gitlab.kitware.com/cmake/cmake/-/issues/18740GetPrerequisites: Location of dumpbin.exe needs to be updated for Visual Stud...2018-12-31T15:31:15-05:00Craig ScottGetPrerequisites: Location of dumpbin.exe needs to be updated for Visual Studio 2017+The `GetPrerequisites` module has some [embedded search paths](https://gitlab.kitware.com/cmake/cmake/blob/v3.13.2/Modules/GetPrerequisites.cmake#L655) for the `gp_cmd_paths` it should search in when trying to locate the appropriate tool...The `GetPrerequisites` module has some [embedded search paths](https://gitlab.kitware.com/cmake/cmake/blob/v3.13.2/Modules/GetPrerequisites.cmake#L655) for the `gp_cmd_paths` it should search in when trying to locate the appropriate tool. These paths appear to only account for Visual Studio 2015 or older and should be updated for more recent VS versions.https://gitlab.kitware.com/cmake/cmake/-/issues/18469Android: Standalone toolchain API level detection no longer working with NDK 182018-12-31T14:03:23-05:00MvdHurkAndroid: Standalone toolchain API level detection no longer working with NDK 18If you are using Android NDK 18b standalone then you are getting always a warning that the API level can't be identified. This seems to be caused by the fact that no longer the API level is embedded in the `clang` binary and neither in t...If you are using Android NDK 18b standalone then you are getting always a warning that the API level can't be identified. This seems to be caused by the fact that no longer the API level is embedded in the `clang` binary and neither in the unified API header file.
For example is it an option to silence this warning in case of these NDK versions (and newer ones)?https://gitlab.kitware.com/cmake/cmake/-/issues/18348Order of specified LANGUAGES impacts Fortran compiler discovery2018-12-31T11:11:58-05:00Jean-Christophe Fillion-RobinOrder of specified LANGUAGES impacts Fortran compiler discoveryAll examples below were tested on Ubuntu and are assumed to have the following structure:
```
cmake_minimum_required(VERSION 3.12)
<TESTCASE>
message("CMAKE_Fortran_COMPILER: [${CMAKE_Fortran_COMPILER}] / CMAKE_Fortran_COMPILER_ID: [$...All examples below were tested on Ubuntu and are assumed to have the following structure:
```
cmake_minimum_required(VERSION 3.12)
<TESTCASE>
message("CMAKE_Fortran_COMPILER: [${CMAKE_Fortran_COMPILER}] / CMAKE_Fortran_COMPILER_ID: [${CMAKE_Fortran_COMPILER_ID}]")
```
----
* where `/usr/bin/f95` is discovered during configuration using any of these `<TESTCASE>`:
```
project(test LANGUAGES Fortran C)
```
```
project(test NONE) # or project(test LANGUAGES NONE)
enable_language(Fortran)
enable_language(C)
```
```
project(test Fortran)
enable_language(C) # this can also be removed with same effect
```
----
* where `/usr/bin/gfortran` is discovered during configuration using any of these `<TESTCASE>`:
```
project(test LANGUAGES C Fortran)
```
```
project(test NONE) # or project(test LANGUAGES NONE)
enable_language(C)
enable_language(Fortran)
```
```
project(test C) # this can also be removed with same effect
enable_language(Fortran)
```https://gitlab.kitware.com/cmake/cmake/-/issues/18705Build products created outside build directory2018-12-29T05:22:55-05:00Lee ButlerBuild products created outside build directoryPlatform: Windows 10
CMake Version: 3.13.1
Compiler: Visual Studio Community 2017
Issue: Build products are being created outside the build directory.
Reproduce by:
1) create project directory
2) place attached CMakeLists.txt...Platform: Windows 10
CMake Version: 3.13.1
Compiler: Visual Studio Community 2017
Issue: Build products are being created outside the build directory.
Reproduce by:
1) create project directory
2) place attached CMakeLists.txt file into project directory.
3) generate via:
>>>
md build\compile
cd build\compile
cmake -G"Visual Studio 15 2017 Win64" ..\\..
>>>
4) Open solution build\compile\cm.sln in Visual Studio 2017
6) Right click on "INSTALL" target and select "Build"
6) note that `build/cm.dir` and `build/x64` directories are created
[CMakeLists.txt](/uploads/af0548276d924795048346d45262802c/CMakeLists.txt)
This is troublesome since the more common practice is to create a single directory "build" for the generated build system and doing the actual compilation. This puts build products in the source tree where they become subject to revision control and configuration management practices.
Note that this does NOT manifest when the build is invoked as:
cmake --build . --config Release --target INSTALL
This seems to be a result of some un-prefixed references to $(IntDir) in the Studio database.