cmake

-fno-unwind-tables and -fno-asynchronous-unwind-tables does not work NDK clang++

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-23 14:09:00
问题 I'm compiling my C++ code using clang++ that comes with ndk21. I've set both compiler flags -fno-unwind-tables and -fno-asynchronous-unwind-tables but the number of entries in the unwind table do not reduce. I also checked by setting the opposite -funwind-tables and -fasynchronous-unwind-tables but it doesn't increase either. setting -fno-exceptions does reduce the number of entries slightly which makes me think I'm passing the flags correctly. Does anyone have any idea why this could be the

#ifdef DEBUG with CMake independent from platform

我怕爱的太早我们不能终老 提交于 2020-06-22 05:09:07
问题 I am using CMake for building my projects on Windows (Visual Studio) as well as on Linux machines(gcc). I'd like to mark some code as "debugging only", like with #ifdef DEBUG //some logging here #endif The question is: what compiler definition is available on all platforms in the CMake "Debug" build type? DEBUG seems not to exist. (I want to have the logging or whatever only when the build type is Debug.) 回答1: CMake adds -DNDEBUG to the CMAKE_C_FLAGS_{RELEASE, MINSIZEREL} by default. So, you

CMake detects a wrong version of OpenCL

这一生的挚爱 提交于 2020-06-22 04:23:05
问题 Following this post, where I have used these instructions to install NVIDIA's OpenCL SDK. The clinfo tool detects a 1.2 OpenCL version correctly. However, The below CMakeLists.txt file: cmake_minimum_required(VERSION 3.1) project(OpenCL_Example) find_package(OpenCL REQUIRED) include_directories(${OpenCL_INCLUDE_DIRS}) link_directories(${OpenCL_LIBRARY}) add_executable(main main.c) target_include_directories(main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(main ${OpenCL_LIBRARY})

Compiling clinfo with NVIDIA's OpenCL SDK leads to error C2061: syntax error: identifier 'cl_device_affinity_domain'

早过忘川 提交于 2020-06-17 09:45:29
问题 Following this issue, I'm trying to compile the clifo tool using the MSVC toolchain. I use this CMakeLists.txt file which successfully finds NVIDIA's OpenCL SDK: Found OpenCL: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v3.2/lib/Win32/OpenCL.lib (found version "1.1") However when compiling with cmake --build . I get many errors, from which the first one is: c:\path\to\clinfo\src\info_ret.h(43): error C2061: syntax error: identifier 'cl_device_affinity_domain' [C:\path\to\clinfo\build

CMake and non-standard extensions

独自空忆成欢 提交于 2020-06-16 05:23:09
问题 I have some C++ source code that, for a valid reason, does not end in ".cpp" or ".cc" or any other usual C++ extension. I would like to compile this into an executable with CMake. My very simple CMake script currently is: CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(test) SET_SOURCE_FILES_PROPERTIES(test_mycode.foo PROPERTIES LANGUAGE CXX) ADD_EXECUTABLE(test test_mycode.foo) As far as I understand, SET_SOURCE_FILES_PROPERTIES(...) should be all that is needed to make Cmake recognize "test

How to dynamically register class in a factory class at runtime period with c++

旧城冷巷雨未停 提交于 2020-06-16 04:05:13
问题 Now, I implemented a factory class to dynamically create class with a idenification string, please see the following code: void IOFactory::registerIO() { Register("NDAM9020", []() -> IOBase * { return new NDAM9020(); }); Register("BK5120", []() -> IOBase * { return new BK5120(); }); } std::unique_ptr<IOBase> IOFactory::createIO(std::string ioDeviceName) { std::unique_ptr<IOBase> io = createObject(ioDeviceName); return io; } So we can create the IO class with the registered name: IOFactory

Cmake Cannot specify include directories when use target target_include_directories

你说的曾经没有我的故事 提交于 2020-06-16 03:06:38
问题 I'm using the submodule GitHub inside my project and now I want to use the target_include_directories for including the file inside the my project class This is my cmake configuration cmake_minimum_required(VERSION 3.9) project(SpyCBlock) set(CMAKE_CXX_STANDARD 14) #bitcoin rpc lib find_library(bitcoinapi 0.3 REQUIRED) target_include_directories(rapidjson PUBLIC include/rapidjson/include) target_include_directories(spycblockrpc PUBLIC include/spycblockrpc) target_include_directories

Cmake Cannot specify include directories when use target target_include_directories

萝らか妹 提交于 2020-06-16 03:06:33
问题 I'm using the submodule GitHub inside my project and now I want to use the target_include_directories for including the file inside the my project class This is my cmake configuration cmake_minimum_required(VERSION 3.9) project(SpyCBlock) set(CMAKE_CXX_STANDARD 14) #bitcoin rpc lib find_library(bitcoinapi 0.3 REQUIRED) target_include_directories(rapidjson PUBLIC include/rapidjson/include) target_include_directories(spycblockrpc PUBLIC include/spycblockrpc) target_include_directories

How to compare files in CMake

旧巷老猫 提交于 2020-06-15 06:45:27
问题 Is there a way to compare files using cmake? I've checked all parameters from https://cmake.org/cmake/help/latest/command/file.html 回答1: cmake executable has a tool mode, when it performs some useful actions instead of project's configuration. And compare_files is one of the commands for that mode. For get features of the CMake command line tool mode in the CMakeLists.txt , use execute_process command: execute_process( COMMAND ${CMAKE_COMMAND} -E compare_files <file1> <file2> RESULT_VARIABLE

Linking freetype with cmake

ε祈祈猫儿з 提交于 2020-06-14 05:03:31
问题 I'm having troubles with linking freetype 2 under linux using cmake when building a C++11 project with an extern C library. With cmake and freetype 2 I basically have 2 options : use the utility freetype-config like freetype-config --libs use the FindFreetype cmake module Now I'm trying to implement the second option and I'm not very skilled with cmake nor I understand the logic of it. My problem is the linking phase, I have no idea how to do that properly plus this module is not as complete