Search code examples
cmakebuilddirectory

How to navigate in cmakelists.txt?


I have project dependency packages in the directory

C:/Users/king/my/mytest/dds

mytest contains folders dds, Source, testapp

I use the following in my cmakelists.txt

find_package(Idlpp-cxx REQUIRED PATHS C:/Users/king/my/mytest/dds/Idlpp-cxx)

find_package(CycloneDDS REQUIRED PATHS C:/Users/king/my/mytest/dds/CycloneDDS)

find_package(CycloneDDS-CXX REQUIRED PATHS C:/Users/king/my/mytest/dds/CycloneDDS-CXX)

how can I set them to pick up automatically without hardcoding C:/Users/king/my/mytest/? which will differ from pc to pc....

I do cmake build in this folder

C:/Users/king/my/mytest/testapp

cmaklists.txt file is in

C:/Users/king/my/mytest/Source


Solution

  • CMAKE_CURRENT_SOURCE_DIR can be used to pick any forward directory from the current directory

     Idlpp-cxx PATHS ${CMAKE_CURRENT_SOURCE_DIR}/my/mytest/dds/idlpp-cxx) 
    

    worked for me