Last active
September 14, 2024 05:58
-
-
Save weimeng23/3a2eeee572e12776385ba4466261f2be to your computer and use it in GitHub Desktop.
Demo CMakeLists.txt for learning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | |
# 设置项目名称 | |
project(LearnCmake VERSION 1.0 LANGUAGES CXX) | |
# 添加可执行文件 | |
add_library(add STATIC add.cc) | |
add_executable(main main.cc) | |
# 添加头文件搜索路径 | |
# include_directories(include) | |
# 添加链接库搜索路径 | |
# link_directories(lib) | |
# 添加头文件 | |
target_include_directories(main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | |
target_include_directories(add PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | |
# 添加链接库 | |
target_link_libraries(main PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/lib/libadd.a) | |
# 设置编译器标志 | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -fPIC") | |
# 设置生成的可执行文件输出路径 | |
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) | |
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) |
Author
weimeng23
commented
Sep 14, 2024
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment