same directory, multiple source files
Write the power function in the previous main.c into a MathFunctions.c source file separately. The file structure in the directory is as follows:
./Demo2
|
+--- main.c
|
+--- MathFunctions.c
|
+--- MathFunctions.h
CMakeLists.txt编写
The content is as follows:
1 # CMake minimum version number required 2 cmake_minimum_required (VERSION 2.8 ) 3 #Project information 4 project (Demo2) 5 #Find all source files in the current directory 6 #And save the name to the DIR_SRCS variable 7 aux_source_directory (. DIR_SRCS) 8 #Specify Build target 9 add_executable(Demo ${DIR_SRCS})