c++ - 如何使用文件夹路径和cmake“链接所有”动态和/或静态库?
问题描述
在我的测试项目中,我的文件夹结构如下
-Root/
-Lib_so/ //folder where it contains all of the .so file
-Lib_a/ //folder where it contains all of the .a file
-Lib_dll/ //folder where it contains all of the dll file
-Includes/ //folder where it contains all of the header files
-main.cpp
我想编写一个生成单个可执行文件的 CMakeLists.txt:
- 仅通过上面显示的文件夹路径自动链接所有 .so 、 .a 和/或 dll 文件。
- 链接已安装的二进制文件(例如 mac 上 brew 安装的 GLFW)
我试过以下
cmake_minimum_required(VERSION 3.0)
project(FirstOpenGL)
set(SOURCE main.cpp)
add_executable(myapp ${SOURCE})
#Below Im trying to link ALL of the libs under the "project's local path"
include_directories(${CMAKE_SOURCE_DIR}/Includes)
link_directories(LinkPathSo ${CMAKE_SOURCE_DIR}/Lib_so)
link_directories(LinkPathA ${CMAKE_SOURCE_DIR}/Lib_a)
link_directories(LinkPathDll ${CMAKE_SOURCE_DIR}/Lib_dll)
target_link_libraries(myapp LinkPathSo)
target_link_libraries(myapp LinkPathA)
target_link_libraries(myapp LinkPathDll)
# Below: Im trying to link the installed binaries on mac
find_package(glfw3 3.2 REQUIRED)
find_package(OpenGL REQUIRED)
target_include_directories(myapp ${OPENGL_INCLUDE_DIR})
target_link_libraries(myapp ${OPENGL_gl_LIBRARY})
target_link_libraries(myapp ${OPENGL_glu_LIBRARY})
谢谢大家
解决方案
推荐阅读
- python-3.x - Many2many字段表未定义的odoo,无法获取多个many2many字段
- python - python lambda函数是否可以更新对象的属性?
- python - 通过一系列奇数/偶数跳转到达数组的末尾
- python-3.x - 为什么我不能从 mac 终端安装 AppKit?
- flutter - 具有动态宽度的行内的 ListView
- api - 使用已弃用的 Google Infographics API 是个好主意
- javascript - Angularx Social Facebook 登录弹出对话框在 FB 移动浏览器中被阻止
- javascript - 在新选项卡中打开时显示“404 page not found”错误的 React 应用程序
- swiftui - 自定义 SwiftUI 颜色的暗模式
- python - For循环将属性与python中的相应值对齐