Error generated when using generator expressions in add_compile_options() at project level.
Hi!
When we call conan_cmake_run this error message is generated c++: error:$<$<COMPILE_LANGUAGE:C>:_some_flag_>: No such file or directory is created. This is because we call CMake's add_compile_options with the generator expression $<$<COMPILE_LANGUAGE:C>:_some_flag_>, prior to calling conan_cmake_run.
- Should
conan_cmake_runbe called before any directory compile or linker options are set (or any other generator expression capable commands are called) - Is it reasonable for
cmake-conanto accept generator expressions used in cmake commands?
-- Conan: Installing config from /dir/conan/config
Installing settings.yml
Defining remotes from remotes.txt
-- Conan: Automatic detection of conan settings from cmake
c++: error: $<$<COMPILE_LANGUAGE:C>:-Werror-implicit-function-declaration>: No such file or directory
-- Conan: Settings= -s;build_type=Release;-s;compiler=gcc;-s;compiler.version=5;-s;compiler.libcxx=libc++;-s;compiler.libcxx=libstdc++11;-s;arch_build=x86_64
RUNNING CMAKE INSTALL
-- Conan: checking conan executable
-- Conan: Found program /usr/bin/conan
-- Conan: Version found Conan version 1.21.1
-- Conan executing: /usr/bin/conan install /dir/conan/conanfile.py -s build_type=Release -s compiler=gcc -s compiler.version=5 -s compiler.libcxx=libc++ -s compiler.libcxx=libstdc++11 -s arch_build=x86_64 -g=cmake -if=/dir/cmake/packages/conan
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=5
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
conanfile.py: Installing package
Requirements
gtest/1.8.1@proj/stable from 'conan-proj' - Cache
Packages
gtest/1.8.1@proj/stable:0869a516f55eb8774ae6dbb84d944be9823a4dea - Cache
gtest/1.8.1@proj/stable: Already installed!
conanfile.py: Generator cmake_find_package created FindGTest.cmake
conanfile.py: Generator cmake created conanbuildinfo.cmake
conanfile.py: Generator txt created conanbuildinfo.txt
conanfile.py: Generated conaninfo.txt
conanfile.py: Generated graphinfo
-- Conan: Loading conanbuildinfo.cmake
-- Conan: Using autogenerated FindGTest.cmake
-- Found: /home/.conan/data/gtest/1.8.1/proj/stable/package/0869a516f55eb8774ae6dbb84d944be9823a4dea/lib/libgmock_main.a
-- Found: /home/.conan/data/gtest/1.8.1/proj/stable/package/0869a516f55eb8774ae6dbb84d944be9823a4dea/lib/libgmock.a
-- Found: /home/.conan/data/gtest/1.8.1/proj/stable/package/0869a516f55eb8774ae6dbb84d944be9823a4dea/lib/libgtest.a
Hi @srud-irobot !
Should conan_cmake_run be called before any directory compile or linker options are set (or any other generator expression capable commands are called)
Probably yes. conan_cmake_run is to retrieve dependencies, that is a previous step to any kind of building your own code. In normal Conan flow you do:
- conan install: to get the dependencies. This is not calling cmake at all, just generating the
conanbuildinfo.cmakeor equivalent - Build your code, calling cmake or any other build system.
cmake_conan_run() is intended to automate the first step, calling Conan from within CMake. Generator expressions probably doesn't make much sense there, as you cannot control the dependencies via the build system of the consumer (the dependencies might not even be using CMake at all). Any configuration to the dependencies should be provided via options/settings/profile.
Thanks!!
From: James [email protected] Sent: Monday, February 17, 2020 17:18 To: conan-io/cmake-conan [email protected] Cc: Rud, Sam [email protected]; Mention [email protected] Subject: Re: [conan-io/cmake-conan] Error generated when using generator expressions in add_compile_options() at project level. (#201)
Should conan_cmake_run be called before any directory compile or linker options are set (or any other generator expression capable commands are called)
Probably yes. conan_cmake_run is to retrieve dependencies, that is a previous step to any kind of building your own code. In normal Conan flow you do:
- conan install: to get the dependencies. This is not calling cmake at all, just generating the conanbuildinfo.cmake or equivalent
- Build your code, calling cmake or any other build system.
cmake_conan_run() is intended to automate the first step, calling Conan from within CMake. Generator expressions probably doesn't make much sense there, as you cannot control the dependencies via the build system of the consumer (the dependencies might not even be using CMake at all). Any configuration to the dependencies should be provided via options/settings/profile.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_conan-2Dio_cmake-2Dconan_issues_201-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAKX5PP4NN6B7F7FAQHKN2V3RDMSNFA5CNFSM4KW2GQOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMACIDI-23issuecomment-2D587211789&d=DwMCaQ&c=jIGm9aumLIlctTGl0fKZ3w&r=ZqKzf_BcQlcY30eerWCwdQ&m=aCDtP7M87JfUbM1zUS70OVyR_9LZbxBi3j67nVUaoLY&s=FIKf2LhrnBy4HWOUcgEZcf3Fy2w60XCAzRngV0igpdw&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AKX5PP5VS3F5EDUVWX2JCTDRDMSNFANCNFSM4KW2GQOA&d=DwMCaQ&c=jIGm9aumLIlctTGl0fKZ3w&r=ZqKzf_BcQlcY30eerWCwdQ&m=aCDtP7M87JfUbM1zUS70OVyR_9LZbxBi3j67nVUaoLY&s=Fjt8UjxJb98rCiydfk9jBwPuhLAEB-61c41kLxNbBi0&e=.