Article Directory
include_directories
It is equivalent to the -I parameter in the gcc option, and also equivalent to the role of C_INCLUDE_PATH and CPLUS_INCLUDE_PATH in the environment variable.
include_directories("/usr/include/SDL2")
set(MY_INCLUDE /usr/include/SDL2)
include_directories(${
MY_INCLUDE})
find_package(SDL2 REQUIRED)
include_directories(${
SDL2_INCLUDE_DIRS})
link_directories
It is equivalent to the -L parameter in the gcc option and the role of LIBRARY_PATH in the environment variable.
link_directories("/usr/local/lib")
set(MY_LIBRARY /usr/local/lib)
link_directories(${
MY_LIBRARY})
link_libraries
Specify the full path of the library, including the library name
- Used before add_executable
- It seems to be used to link static libraries
- It seems to be deprecated, now use target_link_libraries
target_link_libraries
Equivalent to parameters such as -lm -lpthread -lSDL2 in gcc options, used to link dynamic libraries
- Used after add_executable
- Used to link dynamic libraries
target_link_libraries(myplay SDL2)
target_link_libraries(myplay -lSDL2)
target_link_libraries(myplay libSDL2-2.0.so.0)
target_link_libraries(myplay /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0)
target_link_libraries(myplay
${
OpenCV_LIBS}
-lavcodec
-lavdevice
-lavfilter
-lavformat
-lavutil
-lswresample
-lswscale
-lm
-lSDL2
)