CMake series three: multiple source files - the same directory

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})

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324697481&siteId=291194637