且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CMake库输出的自定义目录

更新时间:2022-11-19 23:24:25

目标属性指定库目标文件所在目录的 LIBRARY_OUTPUT_DIRECTORY

The LIBRARY_OUTPUT_DIRECTORY target property specifies the directory where library target files will be built.

set_target_properties(JE3D PROPERTIES
         LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library)

如果所有的库都在一个目录下,我发现更方便的设置 CMAKE_LIBRARY_OUTPUT_DIRECTORY 变量,用于在创建目标时初始化 LIBRARY_OUTPUT_DIRECTORY 属性。

If all the libraries are in one directory, I find it more convenient to set the CMAKE_LIBRARY_OUTPUT_DIRECTORY variable, which is used to initialize the LIBRARY_OUTPUT_DIRECTORY property when creating a target.

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library)

修改:如果您的目标是静态库,请检查评论

Check comments if your target is a static library