Re: [CMake] Visual Studio generator running custom_command twice
On Thu, 2019-03-14 at 13:30 -0400, frodak17 wrote: > On Thu, Mar 14, 2019 at 12:53 PM frodak17 wrote: > > On Thu, Mar 14, 2019 at 1:13 AM Paul Smith > > wrote: > > > I have a situation where I've created a custom command to > > > generate .cpp > > > > > > files to be compiled (in my case running bison/flex). > > > > > > > > > > > > I'm using CMake 3.13.4 > > > > > > > > > > > > set(MyParserOutput > > > > > > ${OUT_DIR}/MyParser.tab.cpp > > > > > > ${OUT_DIR}/MyParser.tab.hpp) > > > > > > > > > > > > add_custom_target(MyGenParser DEPENDS ${MyParserOutput}) > > > > > > > > > > > > Then I have two different libraries, both depending on this: > > > > > > > > > > > > add_library(OneLib STATIC ${MyParserOutput} ...) > > > > > > > > > add_dependencies(OneLib MyGenparser) > > > > > > > > > > > > > > > > > > add_library(TwoLib STATIC ${MyParserOutput} ...) > > > > > > > > > add_dependencies(TwoLib MyGenparser) > > > > > > > > From add_custom_command() > > Do not list the output in more than one independent target that > > may build in parallel or the two instances of the rule may conflict > > (instead use the add_custom_target() command to drive the > > command and make the other targets depend on that one) Yeah, I did see that in the manual and I do that, as above. It wan't at all clear to me that in addition to those requirements, I ALSO could NOT list the output of the add_custom_command() in any of my other targets. That's unfortunate :(. > In that case you need to keep ${MyParserOutput} and set the GENERATED > properties for the files. > > Also the building the custom target needs to be done in a separate > directory as the add_custom_commands() need to be in a different > CMakeLists.txt file from the libraries. Otherwise the rules get > pulled into the libraries and cause the commands to be run multiple > times. Ouch. That's painful as it could mean moving my code around. However in this case it ended up not being too horrible because my parser input files happened to be in a subdirectory already, so I created a new CMakeLists.txt file there that only ran the generators, then used set(... PARENT_SCOPE) to publish the variables to the parent directory. I did then have to add a GENERATED property to those files in the parent directory, as you noted, so overall it's a bit leaky in terms of abstractions, but it seems to work... now when I run on Windows I see that the generators are run only one time. Thanks for the help!! -- 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 community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] Basic question how to find -lm include and lib dir with find_package or otherwise
Usually you don't need to use the full path to libm, and it's only needed sometimes depending on your compiler and toolchain. I typically use something like the following to deal with both the implicit and explicit scenarios: include(CheckCSourceCompiles) set(LIBM_TEST_SOURCE "#include\nfloat f; int main(){sqrt(f);return 0;}") check_c_source_compiles("${LIBM_TEST_SOURCE}" HAVE_MATH) if(HAVE_MATH) set(LIBM_LIBRARIES) else() set(CMAKE_REQUIRED_LIBRARIES m) check_c_source_compiles("${LIBM_TEST_SOURCE}" HAVE_LIBM_MATH) unset(CMAKE_REQUIRED_LIBRARIES) if(NOT HAVE_LIBM_MATH) message(FATAL_ERROR "Unable to use C math library functions") endif() set(LIBM_LIBRARIES m) endif() target_link_libraries(fooTarget PRIVATE ${LIBM_LIBRARIES}) -- Chuck Atkins Staff R&D Engineer, Scientific Computing Kitware, Inc. On Fri, Mar 15, 2019 at 7:46 AM frodak17 wrote: > > > On Thu, Mar 14, 2019 at 8:53 PM workbe...@gmx.at wrote: > >> Hi everyone, >> >> i'm searching for a way to find the right include dir so that -lm can be >> found, the is not find_package for this, is /usr/lib and /usr/include a >> default because he find it without me adding any include or lib path for >> the build. >> >> >> > It seems strange that you need to do this. In my experience 'm' is just > the math portion of the 'c' library. Depending on which host and toolset > you are using there can be multiple version of the 'm' library depending on > target architecture and other options used. The linker should just use the > correct 'm' library just as it uses the correct 'c' library. It could be > in /usr/lib depending on how the compiler was packaged for your host. > -- > > 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 community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > https://cmake.org/mailman/listinfo/cmake > -- 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 community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] Question about find_packages.
On Fri, 2019-03-15 at 17:03 +0100, workbe...@gmx.at wrote: > Hi everyone, > > i try to use find_packages for clang, i'm on debian and have > installed > libclang-4.0-dev package, now i've the files in > /usr/lib/llvm4-0/lib/libclang-4.0.so and the include in > /usr/lib/llvm-4.0/include/clang - how can i make find_package find > those ?? LLVM contains package config files which give you all of this information. Use find_package() as normal: find_package(LLVM) And then invoke CMake with: $ cmake . -DLLVM_DIR=/usr/lib/llvm-4.0/cmake Kyle -- 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 community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] Question about find_packages.
I allways get the error: CMake Error at CMakeLists.txt:78 (find_package): Could not find a package configuration file provided by "Clang" (requested version 4.0) with any of the following names: libclang-4.0.soConfig.cmake libclang-4.0.so-config.cmake Add the installation prefix of "Clang" to CMAKE_PREFIX_PATH or set "Clang_DIR" to a directory containing one of the above files. If "Clang" provides a separate development package or SDK, be sure it has been installed. -- Configuring incomplete, errors occurred! On 15.03.19 17:03, workbe...@gmx.at wrote: > Hi everyone, > > i try to use find_packages for clang, i'm on debian and have installed > libclang-4.0-dev package, now i've the files in > /usr/lib/llvm4-0/lib/libclang-4.0.so and the include in > /usr/lib/llvm-4.0/include/clang - how can i make find_package find those ?? > > > best regards! > > pEpkey.asc Description: application/pgp-keys -- 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 community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
[CMake] Question about find_packages.
Hi everyone, i try to use find_packages for clang, i'm on debian and have installed libclang-4.0-dev package, now i've the files in /usr/lib/llvm4-0/lib/libclang-4.0.so and the include in /usr/lib/llvm-4.0/include/clang - how can i make find_package find those ?? best regards! pEpkey.asc Description: application/pgp-keys -- 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 community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] XCode target membership
On 3/15/19 1:28 AM, Roman Wüger wrote: > since Xcode 10 I noticed that I must check the Checkbox > (Target membership on the right pane) for my target when I want > that the assets are recognized for the specified target. > > Is there a way to automatically set this option via CMake? The problem > is that when I forget to set this check mark (or it is an automated build), > then no app icon will be set. Please open an issue tracker entry for this. Thanks, -Brad -- 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 community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] Basic question how to find -lm include and lib dir with find_package or otherwise
On Thu, Mar 14, 2019 at 8:53 PM workbe...@gmx.at wrote: > Hi everyone, > > i'm searching for a way to find the right include dir so that -lm can be > found, the is not find_package for this, is /usr/lib and /usr/include a > default because he find it without me adding any include or lib path for > the build. > > > It seems strange that you need to do this. In my experience 'm' is just the math portion of the 'c' library. Depending on which host and toolset you are using there can be multiple version of the 'm' library depending on target architecture and other options used. The linker should just use the correct 'm' library just as it uses the correct 'c' library. It could be in /usr/lib depending on how the compiler was packaged for your host. -- 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 community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake