我们需要使用add_subdirectory()命令在结点间建立父子关系。 add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) source_dir:要添加的子目录的路径,相对于当前 CMakeLists.txt 文件的路径。 binary_dir(可选):构建输出的目录,如果未指定,CMake 会使用 source_dir 作为构建目录。 EXCLUDE_FROM_ALL(可...
math file configure_file \ include_directories add_executable add_library target_link_libraries install \ target_sources add_custom_command add_custom_target \ add_subdirectory aux_source_directory \ set_property set_target_properties define_property) usage() { echo "Error: $0 needs to have an i...
#include "addSubdirectoryTest.h" void test() { std::cout << "子项目测试" << std::endl; } 1. 2. 3. 4. 5. 6. CMakeLists.txt 文件内容: cmake_minimum_required (VERSION 3.8) project(addSubdircotryTest) aux_source_directory(. DIR_MY_LIB_TEST) add_library(addSubdircotryTest ${DI...
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 3 ADD_SUBDIRECTORY( src ) 4 AUX_SOURCE_DIRECTORY(. DIR_SRCS) 5 ADD_EXECUTABLE(main ${DIR_SRCS} ) 6 TARGET_LINK_LIBRARIES( main Test ) 相对于上一篇中单个文件的Cmakelist.txt,这个多个源文件的Cmakelist.txt添加了一下的内容: 第三行,使用命令ADD_SUBDIRE...
CMake 2.8.3共有80条命令,分别是:add_custom_command, add_custom_target, add_definitions, add_dependencies, add_executable, add_library, add_subdirectory, add_test, aux_source_directory, break, build_command, cmake_minimum_required, cmake_policy, configure_file, create_test_sourcelist, define_...
add_subdirectory:这个语句的作用是增加编译子目录。其基本语法格式是: add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) 一共有三个参数,后两个是可选参数. source_dir 源代码目录 指定一个包含CMakeLists.txt和代码文件所在的目录,该目录可以是绝对路径,也可以是相对路径,对于后者相对路径的起点是...
add_executable(hello main.c) (4)aux_source_directory 命令格式: aux_source_directory(<dir> <variable>) 用于将 dir 目录下的所有源文件的名字保存在变量 variable 中。 使用示例: aux_source_directory(. DIR_SRCS) (5)add_subdirectory 命令格式: ...
#CMAKE_CURRENT_SOURCE_DIR上当CMake目录add_subdirectory(../3rdparty ${CMAKE_CURRENT_SOURCE_DIR}) 不指定绝对路径就会报如下错误: CMake Error at CMakeLists.txt:8 (add_subdirectory):add_subdirectory not given a binary directory but the given sourcedirectory "G:/NDKProject/OpenGLES/src/main/cpp/...
如果当前目录下还有子目录时可以使用add_subdirectory,子目录中也需要包含有CMakeLists.txt # sub_dir指定包含CMakeLists.txt和源码文件的子目录位置 # binary_dir是输出路径, 一般可以不指定 add_subdirecroty(sub_dir [binary_dir]) 10. file 文件操作命令 ...
#CMAKE_CURRENT_SOURCE_DIR上当CMake目录 add_subdirectory(../3rdparty ${CMAKE_CURRENT_SOURCE_DIR}) 不指定绝对路径就会报如下错误: CMake Error at CMakeLists.txt:8(add_subdirectory):add_subdirectory not given a binary directory but the given source ...