Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加多个源文件多个目录下不使用静态库的处理 #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Demo3_1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CMake 最低版本号要求

cmake_minimum_required (VERSION 2.8)

# 项目信息

project (Demo3_1)

set(ALL_SOURCES CACHE INTERNAL "All sources to be compiled in this project" )

# 添加 src 子目录

add_subdirectory(src)

# 指定生成目标
include_directories(src)

add_executable(Demo main.cpp ${ALL_SOURCES})

4 changes: 4 additions & 0 deletions Demo3_1/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include"max.h"
int main(int argc,char *argv[]){
max();
}
15 changes: 15 additions & 0 deletions Demo3_1/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 查找当前目录下的所有源文件

# 并将名称保存到 DIR_LIB_SRCS 变量

aux_source_directory(. DIR_LIB_SRCS)

# 生成链接库
set(SDS_STATES_ALL_SOURCES ${PROJECT_SOURCE_DIR}/src/max.cpp)

#add_library (MathFunctions ${DIR_LIB_SRCS})

set(ALL_SOURCES
${SDS_STATES_ALL_SOURCES}
PARENT_SCOPE
)
4 changes: 4 additions & 0 deletions Demo3_1/src/max.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include"max.h"
void max(){
printf("I am max\n");
}
2 changes: 2 additions & 0 deletions Demo3_1/src/max.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include<stdio.h>
void max();