|
Boost : |
Subject: Re: [boost] CMake - one more time
From: Paul Fultz II (pfultz2_at_[hidden])
Date: 2016-04-22 20:30:47
> On Apr 22, 2016, at 4:56 PM, Raffi Enficiaud <raffi.enficiaud_at_[hidden]> wrote:
>
> Le 22/04/16 à 19:42, Paul Fultz II a écrit :
>>
>>> On Apr 20, 2016, at 4:39 PM, Raffi Enficiaud <raffi.enficiaud_at_[hidden]> wrote:
>>> <snip>
>>> I do not like the current state of b2 for many reasons (even though I think it could be really a good build system), but CMake is not covering many features that are currently required by the boost superproject. Until the point where we can consistently build the lib (including the possibly many flavor of the same library - STATIC/SHARED at the same time, etc), run the tests, and generate the documentation (including the possibility to have the boostdoc/quickbook/doxygen toolchain), I do not see any *good* reason to move to cmake.
>>
>> Cmake can do all that you listed there. In addition, I found its easy to generate targets at configure time. So the Fit library actually adds additional tests to test examples and header files. Plus, I can create configuration headers based on whether a something compiles or runs. I believe BB can do the same using virtual targets or something, but I havent clearly figured it out.
>>
> Certainly, CMake can do everything with the appropriate effort. But so far, although I am a CMake user, I do not know how to do this:
>
> - having the same target name with different target properties: like
> set(PROJECT_SRC ....)
> add_library(myproject SHARED ${PROJECT_SRC})
> add_library(myproject STATIC ${PROJECT_SRC})
>
> how do you do that? how do you refer to the appropriate variant?
In cmake, you can create object libraries:
https://cmake.org/cmake/help/v3.5/command/add_library.html#object-libraries
This help avoid the double compile, so you can write this:
add_library(objlib OBJECT ${SOURCES})
# shared libraries need PIC
set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(MyLib_shared SHARED $<TARGET_OBJECTS:objlib>)
add_library(MyLib_static STATIC $<TARGET_OBJECTS:objlib>)
Then to set each one to the same name you can use the OUTPUT_NAME property:
set_target_properties(MyLib_shared PROPERTIES OUTPUT_NAME MyLib)
set_target_properties(MyLib_static PROPERTIES OUTPUT_NAME MyLib)
>
> - having a set of dependencies that is not driven by a high level CMakeLists.txt. You advocate the solution of packaging, but this does not target all platforms,
How does this not target all platforms?
> and just translates the same problem to another layer to my opinion. As a developer, in order to work on a library X that depends on Y, you should install Y, and this information should appear in X (so this is an implicit knowledge). What this process does is that it put X and Y in some same level of knowledge: a flatten set of packages. This is done by BJam already the same, but at compilation/build step, and without the burden of the extra management of packages (update upstream Y for instance, when Y can be a set of many packages, and obviously in a confined, repeatable and isolated development environment). But maybe you think of something else.
I dont follow this at all. For example, when I want to build the hmr library here: https://github.com/pfultz2/hmr
All I have to do after cloning it is: `cget build`, then it will go and grab the dependencies because they have been listed in the requirements.txt file.
>
> To me this is a highly non trivial task to do with CMake, and ends up in half backed solutions like ROS/Catkin (http://wiki.ros.org/catkin/conceptual_overview), which is really not CMake and is just making things harder for everyone.
Cmake already handles the packaging and finding dependencies, cget just provides the mechanism to retrieve the packages using the standard cmake process. This why you can use it to install zlib or even blas, as it doesnt require an extra dependency management system.
>
> - I can continue... such as targets subset selection. It is doable with CMake with, "I think" some umbrella projects, but again this is hard to maintain and requires a high level orchestration. Only for the tests for instance: suppose I do not want to compile them in my first step, and then I change my mind, I want to run a subset of them. What I also want is not wasting my time in waiting for a billion of files to compile, I just want the minimal compilation. So it comes to my mind that EXCLUDE_FROM_ALL might be used, but when I run ctest -R something*, I get an error... Maybe you know a good way of doing that in cmake?
I usually add the tests using this(I believe Boost.Hana does the same):
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -VV -C ${CMAKE_CFG_INTDIR})
function(add_test_executable TEST_NAME)
add_executable (${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
if(WIN32)
add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} COMMAND ${TEST_NAME}${CMAKE_EXECUTABLE_SUFFIX})
else()
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
endif()
add_dependencies(check ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
endfunction(add_test_executable)
Then when I want to build the library I just run `cmake build .` and then when I want to run the test, I can run `cmake build . target check`. Now if I want to run just one of the tests I can do `cmake build . target test_name && ./test_name` just as easy. I have not ever had the need to run subset of tests, this is usually the case when there is nested projects, but is easily avoided when the project is separated into separate components.
>
>
>> Finally, for boost, it could provide some high-level cmake functions so all of these things can happen consistently across libraries.
>
> Sure. Or ... BJam should be given some more care and visibility, like a GSoC (bis) track?
But its not entirely technology that is missing, its the community that is missing, and I dont think a GSoC will help create a large community for boost build.
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk