-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatibility with add_subdirectory #8
Comments
Sorry, I was absorbed by other tasks on the project. |
I pushed some changes. |
@ycollet thanks for your work on this! Later today I will test locally as well and let you know if anything comes up |
It seems that everything is set correctly in terms of using I am still experiencing a bizarre issue where CMake segfaults when entering the subdirectory for However I think this is much more likely to be an issue with CMake rather than with your CMakeLists.txt scripts. I will see if I can reduce it to a minimal failing example and open a bug with CMake. |
That's odd ... |
I am on Ubuntu 16.04 operating in the Windows Substem for Linux on a Windows 10 machine. When invoking CMake through Windows an issue shows up in the same place as well, although a segfault is not reported. I will indeed try compiling a later version of CMake to see if the issue persists. |
Today I did some experimenting with continuous integration builds which run on a project at my work. I was able to determine that the CMake segfault issue appears to be local to my machine as that step went fine on the cloud build machine. However the build failed I believe due to an issue with the way include paths are set. I am experimenting with a fix on my fork https://github.com/cstratopoulos/coinor-cmake/tree/feature/target_link and will report back with results. I believe the issue is with target property transitivity. I notice, for example, that in subdirectories such as Clp/Clp, Clp/Osi, etc. there is some duplication. For example in Clp/Clp/CMakeLists.txt, we have the macro which adds the include directory Are you familiar with the propagation of properties through the
Next there is Clp which depends on CoinUtils:
note that we did not have to specify any of the include directories for CoinUtils; these are automatically propagated since they are public properties of the Similarly in
again we don't have to manually specify any paths related to CoinUtils, and the linking is automatic. And finally for OsiClp which naturally depends on Osi and Clp, we can just do
this removes the need for
With all this done, the CMakeLists.txt for my file may have a line such as This will make the targets for CoinUtils, Osi, Clp, and OsiClp visible in my project. At which point I just have to write
then my target will automatically be linked against I realize this is another large-scope change, and I apologize for not being able to contribute further other than the sketch I've laid out above and the changes in my fork. The fork shows a quick workaround for what I hoped to get the build succeeding as quickly as possible, but taking the modern CMake, targets-based approach may have some pretty dramatic impacts in terms of being able to reduce code duplication and ease maintenance of the CMakeLists.txt files. |
Sorry just a quick update:
|
This relates to an issue mentioned in #7: the coinor-cmake subprojects are incompatible with
add_subdirectory
from a parent project.The main problem is the use of
CMAKE_[SOURCE|BINARY]_DIR
rather thanCMAKE_CURRENT_[SOURCE|BINARY]_DIR
. I have made some attempts to fix this myself when focused just on usinglibClp
withlibOsiClp
; the changes are in this patch file:https://pastebin.com/BzmFd0wM
which you can try with
git apply
. But basically:Clp/CMakeLists.txt
needs the_CURRENT_
infix addedClp/Clp
,Clp/CoinUtils
, instances of, e.g.,${CMAKE_SOURCE_DIR}/CoinUtils
need to be replaced with just${CMAKE_CURRENT_SOURCE_DIR}
.I suspect there may be remaining issues with
coin-macros
but I'm not sure.I can't seem to verify if this patch works or not however. When running on Visual Studio 2017 15.9 and also on the Windows Subsystem for Linux, cmake encounters a segmentation fault in the
CoinUtils
directory. I have been able to isolate this to the point whereadd_library(libCoinUtils ...)
is called, but I can't seem to figure out why it happens.The text was updated successfully, but these errors were encountered: