Skip to content

如何引用Installation 中的库 #2

@ted8201

Description

@ted8201

教程写得非常棒。在Installation
中提到了“在其他项目中可以使用

find_package(MyMath 1.0)
target_linked_library(otherapp MyMath::mymath)

我在自己的工程中,这样编写的cmake

cmake_minimum_required(VERSION 3.0)    
project(hi VERSION 0.1) 
add_executable(hi main.cpp)  
set(MyMath_DIR /opt/repos/cmake-tuts-repos/CMakeTutorial-master/Installation/build/mymath/lib/cmake/MyMath/)                               
find_package(MyMath) 
if(MyMath_FOUND) 
    message("MyMath found")  
    target_include_directories(hi PUBLIC ${MyMath_INCLUDE_DIR}) 
    message("include dir ${MyMath_INCLUDE_DIR}")   
    target_link_libraries(hi MyMath::mymath)       
else(MyMath_FOUND)     
    message("MyMath not found")   
endif(MyMath_FOUND)          

无法找到对应mymath.h 头文件,能帮我定位一下原因吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions