cmake

How to configure cmake to get an executable not by default

醉酒当歌 提交于 2021-02-05 06:22:22
问题 I have a small project with cmake. I build a lib and an executable. on the development machine I want also an executable that cannot be build on other machines/environments. e.g.: <my-lib> | -- CMakeLists.txt | + -- src/ -> build the lib/archive | |-- lib.c | |-- lib.h | |-- CMakeLists.txt | + -- tool -> build the tool | |-- tool.c | |-- CMakeLists.txt | + -- tests -> build the unit tests | |-- tests.c | |-- CMakeLists.txt I added CMakeLists.txt to all directories. Also an add_executable to

C++ AddressSanitizer with CMakeLists.txt results in asan errors

佐手、 提交于 2021-02-05 05:28:12
问题 Trying to use the AddressSanitizer tool (ASan) on my C++ project, I get a very verbose output full of undefined reference to '__asan_report_store8' and undefined reference to '__asan_report_load8' , and others like __asan_stack_malloc_2 . My project is built with CMake, and I've added the following line to my CMakeLists.txt: add_definitions(-fsanitize=address -g3 -fno-omit-frame-pointer) following these ASan examples: Example with makefile Jason Turner quick intro video Running the above

C++ AddressSanitizer with CMakeLists.txt results in asan errors

痴心易碎 提交于 2021-02-05 05:27:27
问题 Trying to use the AddressSanitizer tool (ASan) on my C++ project, I get a very verbose output full of undefined reference to '__asan_report_store8' and undefined reference to '__asan_report_load8' , and others like __asan_stack_malloc_2 . My project is built with CMake, and I've added the following line to my CMakeLists.txt: add_definitions(-fsanitize=address -g3 -fno-omit-frame-pointer) following these ASan examples: Example with makefile Jason Turner quick intro video Running the above

How to set library flags after source file in cmake?

﹥>﹥吖頭↗ 提交于 2021-02-04 21:52:45
问题 I'm trying to compile a project using hwloc with CMake. However, I get a ton of undefined reference errors when linking: undefined reference to `hwloc_get_type_depth' undefined reference to `hwloc_bitmap_zero' [...] According to this answer to a similar question the order of flags is important. So, how can I generate a command like this in CMake? : g++ -Wall -std=c++11 source.cpp -lhwloc Excerpt from my CMakeLists.txt: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -lhwloc") set

How to build as an ia32 solution from visual studio using cmake

僤鯓⒐⒋嵵緔 提交于 2021-02-04 21:28:32
问题 I have a module project using cmake with the following configuration: cmake_minimum_required(VERSION 3.13) project(app) set(CMAKE_CXX_STANDARD 11) add_library(app MODULE src/library.cpp src/library.h) Once solution generated using cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release , I can find an app.sln solution. I open it with Visual Studio 2019 and click on the button Local Windows Debugger . I can see also a drop-down menu containing the value x64 and an item

How to build as an ia32 solution from visual studio using cmake

纵饮孤独 提交于 2021-02-04 21:28:29
问题 I have a module project using cmake with the following configuration: cmake_minimum_required(VERSION 3.13) project(app) set(CMAKE_CXX_STANDARD 11) add_library(app MODULE src/library.cpp src/library.h) Once solution generated using cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release , I can find an app.sln solution. I open it with Visual Studio 2019 and click on the button Local Windows Debugger . I can see also a drop-down menu containing the value x64 and an item

How to build as an ia32 solution from visual studio using cmake

让人想犯罪 __ 提交于 2021-02-04 21:28:07
问题 I have a module project using cmake with the following configuration: cmake_minimum_required(VERSION 3.13) project(app) set(CMAKE_CXX_STANDARD 11) add_library(app MODULE src/library.cpp src/library.h) Once solution generated using cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release , I can find an app.sln solution. I open it with Visual Studio 2019 and click on the button Local Windows Debugger . I can see also a drop-down menu containing the value x64 and an item

CMake: wrong build target directory

≯℡__Kan透↙ 提交于 2021-02-04 19:20:43
问题 System : Linux anon-S 3.19.0-31-generic #36~14.04.1-Ubuntu SMP Thu Oct 8 10:21:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux CMake Version : anon@anon-S:~/$ cmake --version cmake version 3.2.2 Main CMakeLists.txt : cmake_minimum_required(VERSION 3.0) set(CMAKE_CXX_STANDARD 11) add_subdirectory(${PROJECT_SOURCE_DIR}/src) add_subdirectory(${PROJECT_SOURCE_DIR}/test) But anon@anon-S:/home/anon/project/build$ cmake .. -- Configuring done -- Generating done -- Build files have been written to: /home

In CMake how do turn a multi line output of a command into a list?

大兔子大兔子 提交于 2021-02-04 18:09:45
问题 I want to do do something like this execute_process( COMMAND bash -c "git --git-dir ${CMAKE_SOURCE_DIR}/.git ls-files" OUTPUT_VARIABLE TRACKED_FILES) add_custom_target(all_file_project SOURCES ${TRACKED_FILES}) And the command itself seems to work as expected but the generated variable "TRACKED_FILES" contains only one logical entry (one multi line string) rather than a list of files. Can I somehow turn a string containing multiple lines separated by a newline ("\n") into a list in CMake? 回答1

In CMake how do turn a multi line output of a command into a list?

喜你入骨 提交于 2021-02-04 18:09:29
问题 I want to do do something like this execute_process( COMMAND bash -c "git --git-dir ${CMAKE_SOURCE_DIR}/.git ls-files" OUTPUT_VARIABLE TRACKED_FILES) add_custom_target(all_file_project SOURCES ${TRACKED_FILES}) And the command itself seems to work as expected but the generated variable "TRACKED_FILES" contains only one logical entry (one multi line string) rather than a list of files. Can I somehow turn a string containing multiple lines separated by a newline ("\n") into a list in CMake? 回答1