GVKun编程网logo

如何在Windows上将GoogleTestvariablesGTEST_LIBRARY GTEST_INCLUDE_DIR和GTEST_MAIN_LIBRARY设置为CMake?

21

在这里,我们将给大家分享关于如何在Windows上将GoogleTestvariablesGTEST_LIBRARYGTEST_INCLUDE_DIR和GTEST_MAIN_LIBRARY设置为CMa

在这里,我们将给大家分享关于如何在Windows上将GoogleTestvariablesGTEST_LIBRARY GTEST_INCLUDE_DIR和GTEST_MAIN_LIBRARY设置为CMake?的知识,同时也会涉及到如何更有效地10 Interesting JavaScript and CSS Libraries for February 2020、c – cmake:我必须以哪种顺序指定TARGET_LINK_LIBRARIES、cmake find_package 中,include_directories,target_link_libraries 的值怎么知道?、cmake set_target_properties INCLUDE_DIRECTORIES在linux上被忽略的内容。

本文目录一览:

如何在Windows上将GoogleTestvariablesGTEST_LIBRARY GTEST_INCLUDE_DIR和GTEST_MAIN_LIBRARY设置为CMake?

如何在Windows上将GoogleTestvariablesGTEST_LIBRARY GTEST_INCLUDE_DIR和GTEST_MAIN_LIBRARY设置为CMake?

有一个为Linux环境开发的项目。 现在我正试图在使用CMake的Windows上构build它。

我一直试图build立该项目,总是得到这个错误:

CMake Error at C:/Program Files(x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) Call Stack (most recent call first): C:/Program Files(x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) C:/Program Files(x86)/CMake/share/cmake-3.3/Modules/FindGTest.cmake:204 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) C:/Users/awy9/git/cmake_modules/modules/SigeoGTest.cmake:21 (find_package) C:/Users/awy9/git/cmake_modules/modules/SigeoInit.cmake:29 (include) CMakeLists.txt:12 (include)

我怎样才能设置这些variables现在在Windows上的这个项目上工作?

如何将C ++变体转换为JSON?

如何在linux内核空间获取当前小时(一天中的时间)

GUID的唯一性

如何使Qt Widget填充父窗口小部件?

在Mac OS X上安装第三方C库

从Windows服务获取用户根目录

如何locking并强制用户重新input自己的Windows密码?

错误:在我的Makefile中“混合隐式和静态模式规则”

如何使脚本在Linux使用我的interpteter和工作? (#!)

使用MinGW生成在64位系统上编译一个32位的exe文件 – 编译一个32位的exe文件,但链接到64位的dll

UPDATE

@Tsyvarev帮我解决了第一个问题,我引用他的话:

这是标准的CMake消息,当没有找到请求的包(GTest在你的情况下)。 您应该在配置您的项目之前安装GTest。 或者,如果您已经将其安装到非标准位置,请通过GTEST_ROOT变量传递此位置:cmake -DGTEST_ROOT = …

作为cmake传递变量的替代方法,可以设置环境变量:set GTEST_ROOT =

这解决了与GTEST_INCLUDE_DIR的值的问题 ,但我仍然有这些错误:

CMake错误在C:/ Program Files(x86)/CMake/share/cmake-3.3/modulees/FindPackageH andleStandardArgs.cmake:148(消息):无法找到GTest(缺少:GTEST_LIBRARY GTEST_MAIN_LIBRARY)

我认为,在Windows环境下,一些价值观与手册所说的不同。

编译Gtest后,我得到了两个库:gtest.lib和gtest_main.lib然后,我设置这些文件路径变量:

GTEST_LIBRARY = C: Users awy9 Softwares Gtest gtest-1.7.0 Debug gtest.lib GTEST_MAIN_LIBRARY = C: Users awy9 Softwares Gtest gtest-1.7.0 Debug gtest_main.lib

现在一切正常!

谢谢

10 Interesting JavaScript and CSS Libraries for February 2020

10 Interesting JavaScript and CSS Libraries for February 2020

https://tutorialzine.com/2020/02/10-interesting-javascript-and-css-libraries-for-february-2020


Our mission at Tutorialzine is to keep you up to date with the latest and coolest trends in web development. That’s why every month we release a handpicked collection of some of the best resources that we’ve stumbled upon and deemed worthy of your attention.

If you enjoy these articles, make sure to subscribe to Dev Awesome. It is our biweekly newsletter where we share cool new libraries, articles, and free design resources!


afrmae.png

A-Frame

A-frame is one of the most popular and feature-packed VR frameworks out there. It''s based on web technologies like HTML and JS, so it''s super easy to get into, while at the same time offering support for most major VR platforms like Vive and Rift. It recently had its official v1.0.0 release and is better than ever.


react-nice-dates.png

React Nice Dates

Touch-friendly datepicker for React with a beautiful design. The library is fully modular, consisting of separate components and utilities which can be mix-and-matched to create the perfect date picker for your needs.


snowpack.png

Snowpack

Revolutionary new tool for bundling JavaScript dependencies. Unlike Webpack and other bundlers, which recompile your assets after every file change, Snowpack does only an initial setup. After everything is compiled, any new changes to your code will be instantly available without a build step.


craft.png

Craft.js

Great React framework that helps you create user-friendly page editors. It makes it possible to change the content of a web page using drag & drop, detailed text controls, media embeds, and more. Perfect for building content management systems and WYSIWYG apps.


yarn.png

Yarn 2

Yarn offers an excellent alternative to NPM with a number of great features like module caching for using it offline and "flat mode" that works great to reduce duplicating packages. The project just released a new major update so make sure to check it out.


playwright.png

Playwright

Playrwight is an awesome node library by the Microsoft team for building automated write-once-run-everywhere UI tests. It covers most browsers that are based on Chromium, WebKit and Firefox, as well as all the major operating systems. The API is really clean and easy to work with, so that you can quickly open pages, manipulate them, and take screenshots.


voxel-space.jpg

VoxelSpace

Interesting GitHub repo for an infinite terrain generator created from scratch. The source code has plenty of comments and is easy to follow, plus the rendering algorithm itself is very well explained in the readme. You can check out the demo here.


web-extension-starter.png

Web Extension Starter

This is a really handy starter kit for creating multi-browser web extensions. It makes it super easy to build web addons for Chrome, Firefox and Opera out of the same code base. The kit covers browser specific APIs, manifests, and build files, to make sure your plugin works everywhere.


mirage.png

Mirage

Powerful API mocking library for writing tests without having an actual backend. Mirage can be configured to recreate complex dynamic scenarios, typically only possible when using a real production server. The setup can then be shared with the rest of your codebase so that the tests run on all teammates'' machines.


panzoom.jpg

Panzoom

As the name suggests, Panzoom is a framework for handling pan and zoom actions in your apps. It works great on mobile, supports both DOM elements and SVGs, and offers plenty of customization options.


Bootstrap Studio

The revolutionary web design tool for creating responsive websites and apps.

Learn more

c – cmake:我必须以哪种顺序指定TARGET_LINK_LIBRARIES

我一次又一次地遇到链接器问题,因为必须以正确的顺序指定TARGET_LINK_LIBRARIES中的所有库.但是我如何确定这个订单呢?例:

我有以下库

libA depends on boost
libB depends on postgresql and libA (and therefore on boost)
myTarget uses libA,libB and boost directly (and through libB depends on postgresql)

由于所有必需的库只在创建可执行文件时被链接,因此在链接myTarget(最终可执行文件)时必须指定所有库:

TARGET_LINK_LIBRARIES(${ApplicationName}  

libboost_program_options.a 
libboost_system.a 
libboost_filesystem.a 
libboost_date_time.a 
libboost_regex.a 

# Should include all boost libraries but strangely some libs (the ones above)
# need to be specified "by hand"???
${Boost_LIBRARIES} 

# Postgresql stuff
libpq.a
libsoci_core.a
libsoci_postgresql.a
libpq.so

# My libs
libB.a
libA.a

${CMAKE_THREAD_LIBS_INIT} # pthreads,needed by boost
${CMAKE_DL_LIBS} # For libdl.so etc.
)

由于我链接boost static我的CMakeLists.txt也包含

SET(Boost_USE_STATIC_LIBS ON)

但是,我仍然会遇到链接错误,例如“对boost :: re_detail :: perl_matcher或boost :: date_time :: month_formatter的未定义引用”

这真的很烦人,我正在改变lib排序和一些未定义的引用消失但出现了新的未定义引用.

如何识别正确的订购?!

编辑:

我通过分别识别libs之间的所有依赖关系并适当地排序它们来解决上面的问题(因此添加了libboost_log.a):

TARGET_LINK_LIBRARIES(${ApplicationName}  
libB.a
libA.a

# Postgresql stuff
libpq.a
libsoci_core.a
libsoci_postgresql.a
libpq.so

# Boost
libboost_program_options.a 
libboost_system.a 
libboost_log.a 
libboost_filesystem.a 
libboost_date_time.a 
libboost_regex.a 
# Should include all boost libraries but strangely some libs (the ones above)
# need to be specified "by hand"???
${Boost_LIBRARIES} 

# Lowlevel needed by boost
${CMAKE_THREAD_LIBS_INIT} # pthreads,needed by boost
${CMAKE_DL_LIBS} # For libdl.so etc.
)

所以订购自上而下. Top是可执行文件,后跟直接使用的库.接下来是进一步的依赖关系,最后必须添加低级依赖关系(由boost使用).

解决方法

在我的情况下,当我想尊重链接我的库的顺序时,我使用 add_dependencies cmake命令.我的意思是:

find_package(Boost COMPONENTS date_time filesystem system ...)
find_package(Postgresql required)
IF(Boost_FOUND AND Postgresql_FOUND)
  INCLUDE_DIRECTORIES(${Boost_INCLUDE_Dirs})
  INCLUDE_DIRECTORIES(${Postgresql_INCLUDE_Dirs})

  # ApplicationName -> your_application
  # LIB_A_TARGET -> libA
  # LIB_B_TARGET -> libB

  SET(LIB_A_ALL_DEPS ${Boost_LIBRARIES})
  SET(LIB_B_ALL_DEPS ${LIB_A_ALL_DEPS} ${Postgresql_LIBRARIES})

  SET(EXTRA_APP_DEPS  ) # here all your extra libs that they aren't in boost or postgre

  SET(YOUR_APP_ALL_DEPS ${LIB_A_ALL_DEPS} ${LIB_B_ALL_DEPS} ${EXTRA_APP_DEPS})

  # Here'll be all your ADD_EXECUTABLE,ADD_LIBRARY code

  TARGET_LINK_LIBRARIES(${LIB_A_TARGET} ${LIB_A_ALL_DEPS})
  ADD_DEPENDENCIES(${LIB_A_TARGET} ${LIB_A_ALL_DEPS})

  TARGET_LINK_LIBRARIES(${LIB_B_TARGET} ${LIB_B_ALL_DEPS})
  ADD_DEPENDENCIES(${LIB_B_TARGET} ${LIB_B_ALL_DEPS})

  TARGET_LINK_LIBRARIES(${ApplicationName} ${YOUR_APP_ALL_DEPS})
  ADD_DEPENDENCIES(${ApplicationName} ${YOUR_APP_ALL_DEPS})
ENDIF()

我没有测试过这段代码,但我会做或多或少.我知道这个例子只是可能的CMakeLists.txt的一部分所以我需要看看你的代码完全写它.

我希望它对你有所帮助!

cmake find_package 中,include_directories,target_link_libraries 的值怎么知道?

Sophus 库为例:

find_package(Sophus REQUIRED)

include_directories(${Sophus_INCLUDE_DIRS})

target_link_libraries(useSophus ${Sophus_LIBRARIES})

我们怎么知道要连接 Sophus_INCLUDE_DIRS,Sophus_LIBRARIES,而不是 SOPHUS_INCLUDE_DIRS,SOPHUS_LIBRARIES 或其他,其实

find_package 主要是找到.cmake 文件,然后这些变量在.cmake 里面定义了,我们看 Sophus/SophusConfig.cmake:

# Sophus source dir

set( Sophus_SOURCE_DIR "/home/xxx/slamcode/ch4/Sophus")

 

################################################################################

# Sophus build dir

set( Sophus_DIR "/home/xxx/slamcode/ch4/Sophus")

 

################################################################################

set( Sophus_INCLUDE_DIR  "/home/xxx/slamcode/ch4/Sophus;/usr/include/eigen3" )

set( Sophus_INCLUDE_DIRS  "/home/xxx/slamcode/ch4/Sophus;/usr/include/eigen3" )

 

set( Sophus_LIBRARIES    "/home/xxx/slamcode/ch4/Sophus/libSophus.so" )

set( Sophus_LIBRARY      "/home/xxx/slamcode/ch4/Sophus/libSophus.so" )

 

set( Sophus_LIBRARY_DIR  "/home/xxx/slamcode/ch4/Sophus" )

set( Sophus_LIBRARY_DIRS "/home/xxx/slamcode/ch4/Sophus" )

 

然后就知道那些变量可以用了吧

 

 

 

cmake set_target_properties INCLUDE_DIRECTORIES在linux上被忽略

cmake set_target_properties INCLUDE_DIRECTORIES在linux上被忽略

我有一堆目标,我试图设置每个目标的包含目录。

set_target_properties (foo PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_Fortran_MODULE_DIRECTORY}/bar)

当我build立( make VERBOSE=1 )这在Mac OS X上得到

... -J../build/modules/foo -I../build/modules/bar

当我在Linux上做同样的事情时,

... -J../build/modules/foo ...

唯一的区别,我可以看到的是,在Mac上,我正在使用cmake 2.8.8,而在Linux上,我正在使用2.8.7。 2.8.8之前的版本不支持这个function吗?

两个OpenCV的安装(不同版本),我不能删除过去的所有痕迹

使用cmakebuild立错误:找不到-lpthreads

Cmake命令行窗口太长

CMakeLists无法find新安装的HDF5?

CMake在linux中构build共享对象.so文件

CMake:C和CXX编译器的标识是Win10的CMakeGUI未知

用cmake构build一个Python共享对象绑定,这取决于外部库

在Windows上使用CMake 2.8.11构build自定义Qt 4.8.3库时出错

FindXXX.cmake文件的本地编译库的正确位置是什么?

Cmake:如何将库标记为依赖于系统库

这种行为确实是从2.8.7到2.8.8版本的变化。

从更新日志 :

为每个目标的INCLUDE_DIRECTORIES调用ExpandVariablesInString

更新有关INCLUDE_DIRECTORIES的文档。 […]

保持INCLUDE_DIRECTORIES目标属性是最新的。

提取并使用INCLUDE_DIRECTORIES目标属性。

特别感兴趣的是改变文档的提交 。 据此,2.8.7中的INCLUDE_DIRECTORIES属性是目录上的只读属性。 该版本中的目标属性根本不存在。

由于CMake允许设置任意的目标属性,所以你的脚本仍然可以正常工作,但是CMake简单的忽略了这个属性。

这是另一个很好的例子,为什么你总是要照顾指定正确的最低要求的版本 。

总结

以上是小编为你收集整理的cmake set_target_properties INCLUDE_DIRECTORIES在linux上被忽略全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

关于如何在Windows上将GoogleTestvariablesGTEST_LIBRARY GTEST_INCLUDE_DIR和GTEST_MAIN_LIBRARY设置为CMake?的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于10 Interesting JavaScript and CSS Libraries for February 2020、c – cmake:我必须以哪种顺序指定TARGET_LINK_LIBRARIES、cmake find_package 中,include_directories,target_link_libraries 的值怎么知道?、cmake set_target_properties INCLUDE_DIRECTORIES在linux上被忽略等相关知识的信息别忘了在本站进行查找喔。

本文标签: