Description
- I've read Brief overview section and do understand basic concepts. Yes
- I've read F.A.Q. section and there is no solution to my problem there. Yes
- I've read Code of Conduct, I promise to be polite and will do my best at being constructive. Yes
- I've read Reporting bugs section carefully. Yes
- I've checked that all the
hunter_add_package
/find_package
API used by me in the example is the same as in documentation. Yes - I'm using latest Hunter
URL
/SHA1
. Yes
- I've created SSCCE reproducing the issue:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.314.tar.gz"
SHA1 "95c47c92f68edb091b5d6d18924baabe02a6962a"
LOCAL
)
project(repro)
hunter_add_package(CURL)
find_package(CURL CONFIG REQUIRED)
add_executable(dummy main.cpp)
target_link_libraries(dummy CURL::libcurl)
#./cmake/Hunter/config.cmake
hunter_config(
CURL
VERSION 7.74.0-p2
CMAKE_ARGS CMAKE_C_FLAGS=-ffunction-sections CMAKE_C_FLAGS=-fdata-sections
)
- I'm building on Linux
- I'm using system CMake
- CMake version: 3.18.4
Expected behaviour
Hunter should pass "-ffunction-sections -fdata-sections" as the value of CMAKE_C_FLAGS.
Actual behaviour
Only the last one is passed.
Other
I also tried the following variations:
CMAKE_ARGS CMAKE_C_FLAGS=-ffunction-sections -fdata-sections
=> Failure parsing arguments.
CMAKE_ARGS CMAKE_C_FLAGS="-ffunction-sections -fdata-sections"
=> Configures fine but cmake fails to build anything.
CMAKE_ARGS CMAKE_C_FLAGS='-ffunction-sections -fdata-sections'
=> Same as double quotes.
I think the problem is in how the arguments are passed to the cmake subproject. If I peek into Build/CURL/args.cmake
in the build directory I get either
set("CMAKE_C_FLAGS" "-ffunction-sections" CACHE INTERNAL "")
set("CMAKE_C_FLAGS" "-fdata-sections" CACHE INTERNAL "")
with multiple arguments or
set("CMAKE_C_FLAGS" ""-ffunction-sections -fdata-sections"" CACHE INTERNAL "")
with quotes.
The proper result is probably something like this:
set("CMAKE_C_FLAGS" "-ffunction-sections -fdata-sections" CACHE INTERNAL "")
I am not familiar with hunter, but assuming args.cmake is loaded into a more or less clean environment it might be the easiest option to modify the generation code to generate this:
set("CMAKE_C_FLAGS" "${CMAKE_C_FLAGS} -ffunction-sections" CACHE INTERNAL "")
set("CMAKE_C_FLAGS" "${CMAKE_C_FLAGS} -fdata-sections" CACHE INTERNAL "")
If there is a different option or I am missunderstanding something please let me know.
EDIT: CMAKE_ARGS CMAKE_C_FLAGS=-ffunction-sections\ -fdata-sections
works, but it feels awfull and is not documented anywhere.