cmake

How to best tell CMake where to find dll

梦想与她 提交于 2020-01-23 02:42:08
问题 I have a simple project structure derived from the amazing tutorial https://rix0r.nl/blog/2015/08/13/cmake-guide/ It looks as follows: - src - CMakeLists.txt - mylib - include/mylib/mylibclass.h - src/mylibclass.cpp - CMakeLists.txt - myapp - src/myapp.cpp - CMakeLists.txt The top level CMakeLists.txt contains: cmake_minimum_required( VERSION 3.6 ) project( sample_project VERSION 0.1 LANGUAGES CXX ) set( BUILD_SHARED_LIBS ON CACHE BOOL "" ) add_subdirectory( mylib ) add_subdirectory( myapp )

find_package does not find GTest which is part of CMake

孤街浪徒 提交于 2020-01-23 02:38:07
问题 I want to find GTest via: find_package(GTest REQUIRED) But it is not found: Error:Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) I know from this link that GTest should be distributed via standard CMake. Can you tell me what I did wrong? 回答1: If you have gtest installed you can just do: add_subdirectory("/usr/src/gtest" ${CMAKE_BINARY_DIR}/gtest) enable_testing() include_directories(${GTEST_INCLUDE_DIRS}) add_executable(test test.cpp) target_link_libraries

CMake使用

给你一囗甜甜゛ 提交于 2020-01-23 02:02:04
文章目录 声明cmake最低版本 声明一个cmake工程 创建库 将可执行程序链接到库上 设置构建类型 指定编译选项 指定所需要的头文件所在目录 声明cmake最低版本 cmake_minimum_required ( VERSION 2.8 ) 声明一个cmake工程 project ( HelloSLAM ) 创建库 静态库 add_library ( hello libHelloSLAM . cpp ) 动态库 add_library ( hello SHARED libHelloSLAM . cpp ) 将可执行程序链接到库上 add_executable ( useHello useHello . cpp ) target_link_libraries ( useHello hello ) 设置构建类型 set ( CMAKE_BUILD_TYPE "Release" ) # Debug 指定编译选项 set ( CMAKE_CXX_FLAGS "-O3" ) 指定所需要的头文件所在目录 include_directories ( / usr / include / eigen3 ) 来源: CSDN 作者: PythonFCG 链接: https://blog.csdn.net/renweiyi1487/article/details/104058691

CMake, Microsoft Visual Studio, and Monolithic Runtimes

为君一笑 提交于 2020-01-22 19:56:31
问题 I'm building a file using the CMake Build System and Microsoft's Visual C++ compiler. When I have CMake generate the visual studio project, the project contains the commandline to build a "Multi Threaded DLL" type of runtime -- one which depends on msvcrt.dll. For various reasons I'm not going into right now, I cannot depend on msvcrt. Is there a way to tell CMake to modify this option in it's construction process? 回答1: I use the following piece of code to link to the static CRT: if(MSVC) #

CMake or Waf for D project

江枫思渺然 提交于 2020-01-22 17:34:46
问题 We are looking for adequate build tool for a desktop GUI application to be written in D (using Qt toolkit), consisting of several native libraries, using 3rd party C-lib(s). It has to build on Linux (native development) and Mac as well on Windows. We might adopt Code::Blocks as IDE. Waf already has support for D language, while CMake is just receiving it cmaked2. CMake uses special language, while Waf is pure Python...Otoh, CMake, via CPack, can produce packages in several formats as well as

How to port a qmake project to cmake

為{幸葍}努か 提交于 2020-01-22 16:47:40
问题 I would like to "port" this C++ project, which uses qmake (i.e., a Tool.pro file) for building, to cmake . Essentially, I'm asking how to go about writing the necessary CMakeLists.txt file(s) by looking at the Tool.pro file above. This is what I've done so far: include_directories(../lib/cudd-2.5.0/include BFAbstractionLibrary) add_executable(slugs BFAbstractionLibrary/bddDump.cpp BFAbstractionLibrary/BFCuddVarVector.cpp BFAbstractionLibrary/BFCudd.cpp BFAbstractionLibrary/BFCuddManager.cpp \

Variables set with PARENT_SCOPE are empty in the corresponding child scope. Why?

百般思念 提交于 2020-01-22 14:03:43
问题 Consider the following minimal example: . ├── bar │ └── CMakeLists.txt └── CMakeLists.txt where ./CMakeLists.txt is project( foo ) cmake_minimum_required( VERSION 2.8 ) set( FOO "Exists in both, parent AND in child scope." ) add_subdirectory( bar ) message( STATUS "Variable BAR in ./ = ${BAR}" ) message( STATUS "Variable FOO in ./ = ${FOO}" ) and ./bar/CMakeLists.txt is set( BAR "Exists in parent scope only." PARENT_SCOPE ) message( STATUS "Variable BAR in ./bar/ = ${BAR}" ) The relevant part

Variables set with PARENT_SCOPE are empty in the corresponding child scope. Why?

眉间皱痕 提交于 2020-01-22 14:02:46
问题 Consider the following minimal example: . ├── bar │ └── CMakeLists.txt └── CMakeLists.txt where ./CMakeLists.txt is project( foo ) cmake_minimum_required( VERSION 2.8 ) set( FOO "Exists in both, parent AND in child scope." ) add_subdirectory( bar ) message( STATUS "Variable BAR in ./ = ${BAR}" ) message( STATUS "Variable FOO in ./ = ${FOO}" ) and ./bar/CMakeLists.txt is set( BAR "Exists in parent scope only." PARENT_SCOPE ) message( STATUS "Variable BAR in ./bar/ = ${BAR}" ) The relevant part

Can Cmake generate a single makefile that supports both debug and release

强颜欢笑 提交于 2020-01-22 10:50:13
问题 It seems like we need to create separate folder for each build type (debug/release), run cmake on each, and generate separate makefile for debug/release configuration. Is it possible to create one single makefile using cmake that supports both debug/release configuration at the same time and when we actually run "make" that will create separate folders for the intermediate and final products (like the dlls, exe). 回答1: As far as I know, this cannot be achieved using a single set of build

Can Cmake generate a single makefile that supports both debug and release

只谈情不闲聊 提交于 2020-01-22 10:50:09
问题 It seems like we need to create separate folder for each build type (debug/release), run cmake on each, and generate separate makefile for debug/release configuration. Is it possible to create one single makefile using cmake that supports both debug/release configuration at the same time and when we actually run "make" that will create separate folders for the intermediate and final products (like the dlls, exe). 回答1: As far as I know, this cannot be achieved using a single set of build