start here
1、资源1
github上的开源项目
https://github.com/ttroy50/cmake-examples
2、资源2
添加链接描述
https://github.com/onqtam/awesome-cmake
里面的分支很详细,新手参考
贴个例子,仅供参考
#指定cmake最小版本,nihao
cmake_minimum_required(VERSION 3.4.1)
project (Testpcm2mp3)
#源文件
set(SOURCES
src/ALSA_AUDIO_CAPTURE.c
src/Lame_pcm2mp3.c
src/testpcm2mp3.cpp
)
include_directories(3rdparty/lame/include/lame/)
link_directories(3rdparty/lame/lib/)
#链接static alsa&lame库
link_libraries(-lasound
)
link_libraries(libmp3lame.so)
add_executable(${PROJECT_NAME} ${SOURCES})
#头文件
target_include_directories(${PROJECT_NAME}
PRIVATE
${PROJECT_SOURCE_DIR}/include
)