How to link a test with a library as obtained in the build directory,
not with the installed version, which may be outdated?
Disclosure: cross-posted from https://stackoverflow.com/questions/56328326.
== Use case ==
Suppose
cmake; make; ctest; make install
works fine:
- generates libA,
-
A gitlab-runner configuration script .gitlab-ci.yml, for execution in the
Powershell:
===
windows:
tags:
- windows
stage: build
script:
- New-Item -ItemType "directory" -Confirm:$false -Force:$true -Name "build"
- cd build
- cmd.exe "C:\Program Files (x86)\Microsoft Visual
The command execute_process has an option TIMEOUT.
This option would be even more useful if one
would notice when a timeout happened.
Is there a way to tell from any of the outcome
variables whether the process ran into timeout?
- Joachim
smime.p7s
Description: S/MIME Cryptographic Signature
Add code like this at the top of your project:
```
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
```
And combine it with
```
link_directories(BEFORE ${PROJECT_BINARY_DIR}/bin)
```
so that tests find the libraries?
Anyway, my problem is not at link time, but when _executing_
The library `mylib` consists of the library proper, in directory `lib/`, and a
test suite, in directory `test/`. It is completely under CMake control:
mylib/CMakeLists.txt:
...
add_subdirectory(lib)
add_subdirectory(test)
...
mylib/lib/CMakeLists.txt:
...
how do these two relate to each other?
- Joachim
smime.p7s
Description: S/MIME Cryptographic Signature
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake
My understanding was that prevalent usage in modern CMake
is all lowercase for function names, all uppercase for
macro names. In this sense, I submitted a number of merge
requests where function and macro names are normalized, and
in
https://gitlab.kitware.com/cmake/cmake/merge_requests/2607
I
if("${srcdir}" STREQUAL "${bindir}")
if(srcdir STREQUAL bindir)
looks more idiomatic, thank you Eike -
But can we be sure that srcdir contains no blank?
Or does STREQUAL work even for argument strings
that contain blanks?
- Joachim
smime.p7s
Description: S/MIME Cryptographic Signature
--
In all my projects, the top-level CMakeLists.txt contains the line
include(PreventInSourceBuilds)
to protect users (and myself) from unintentionally running CMake
in the source directory.
Would you consider adding this little module to the CMake code base?
I would then add an option so that
Project P depends on library L.
L comes with a module FindL.cmake, which is so
complicated that we would not be able to adapt it
to our needs.
On most platforms, users will build P from source,
and dynamically link with L. For them, the line
find_package(L REQUIRED)
in P/CMakeLists.txt works
Somewhere we are advised that Module mode should be phased out in favor of
Config mode.
If Config mode is the newer, preferred way to find a package, I would expect
find_package to first try Config mode, and only fall back to Module mode if
no config scripts can be found. However, according to
Module mode is only selected if there is a Find.cmake
file available. Otherwise Config mode is used anyway. For a given
project's call only one of the modes can be used: the find module
is either present or it is not. If the find module is available
it is used and becomes responsible for
The find_package command docs [1,2] recommend that user code
should generally look for packages using the Module mode
signature. What then about user code that ought to check
for version compatibility? Module mode only offers a check
for an EXACT version string, and does not terminate if
that
FindBoost does not detect absence of header files.
To be specific: Run the following under cmake version 3.5.1:
set(Boost_NO_BOOST_CMAKE ON) # prevent shortcut
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
add_definitions(-DBOOST_ALL_DYN_LINK)
may I invite your comments at
http://codereview.stackexchange.com/questions/105020/a-cmake-module-that-improves-upon-checklibrariesexists
where I am proposing a module AssertLibraryFunction that improves
upon CheckLibrariesExists in two respects:
- It honors the optional argument REQUIRED of
15 matches
Mail list logo