set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) include(CPack) target_include_directories(${PROJECT_NAME} PRIVATE ${GLFW_INCLUDE_DIRS})target_link_libraries(${PROJECT_NAME} PRIVATE GLEW::GLEW ${GLFW_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::OpenGL) 点保存后(或者 CTRL+S...
set(MY_VERSIONINFO_RC"${CMAKE_BINARY_DIR}/VersionInfo.rc") configure_file("${CMAKE_SOURCE_DIR}/VersionInfo.rc.in" "${MY_VERSIONINFO_RC }") endif() 因为是Windows平台特有的机制,所以我们使用条件判断语句判断下是否是MSVC。 .rc模板中的${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},和$...
SET_TARGET_PROPERTIES(hello PROPERTIES VERSION 1.2 SOVERSION 1)#向工程添加多个特定的头文件搜索路径。系统默认的头文件路径是/usr/include和/usr/local/include,如果不是,需要在Cmakelist中显式的定义。INCLUDE_DIRECTORIES([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)#将目标文件链接到第三方库,非常重要的...
CMAKE_MINIMUM_REQUIRED(VERSION 3.8) PROJECT(ExternalMcuUpdateNrf52 C) ADD_EXECUTABLE(${PROJECT_NAME} main.c file_view.c mem_buf.c epoll_timerfd_utilities.c nordic/slip.c nordic/crc.c nordic/dfu_uart_protocol.c) TARGET_LINK_LIBRARIES(${PROJECT_NAME} applibs pthread gcc_s c) SET(ADDITIONA...
message (">>> top CMAKE_PROJECT_NAME: ${CMAKE_PROJECT_NAME}") add_subdirectory (sub_test) # 调用sub_test下的CMakeList.txt进行构建 # test/sub_test/CMakeLists.txt cmake_minimum_required (VERSION 3.10.2) set (SUB_LEVEL_PROJECT_NAME "mysubtest") # 定义了变量SUB_LEVEL_PROJECT_NAME为...
if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() project 函数相关变量 CMake 中的 project 函数会定义一些变量,这些变量可以在 CMakeLists.txt 中使用,也可以在 C++ 代码中使用。 project(myproject VERSION 1.0.0 LANGUAGES CXX) message("PROJECT_NAME: ${PROJECT_NAME}") message("...
1 #我们需要修改的地方:${CMAKE_CURRENT_SOURCE_DIR}/app.rc这是rc文件的路径 2 3 set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/app.rc") 4 if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) 5 qt_add_executable(KR-MACScanner 6 MANUAL_FINALIZATION 7 ${PROJECT_SOURCES} 8 ${app_icon...
CMAKE_MINIMUM_REQUIRED(VERSION3.5)PROJECT(cmake_demoVERSION1.0.0)SET(CMAKE_C_STANDARD99)# 自定义宏,代码中可以使用if(CMAKE_HOST_UNIX)ADD_DEFINITIONS(-DMY_LINUX)else()ADD_DEFINITIONS(-DMY_WINDOWS)endif()ADD_SUBDIRECTORY(mylib)ADD_SUBDIRECTORY(myapp) ...
# 最小Cmake版本,可以灵活更改cmake_minimum_required(VERSION3.13)# 项目名称project(Cars)# 设置编译的C++标准set(CMAKE_CXX_STANDARD11)# 将此目录内的所有源文件都扫面一遍file(GLOBSources*.cpp)file(GLOBIncludes*.h)#编译出可执行文件(一般来说都是这样)add_executable(Cars ${Sources}${Includes}) ...