CMake初级简明教程( 三 )


9.简易示例1
这个是我写的一个DNN库的,这里没有把它编译成lib 。可以作为参考 。
cmake_minimum_required(VERSION 2.8)project(main)# SET(CMAKE_BUILD_TYPE "Release") #可以设定优化为Release# set(CMAKE_CXX_FLAGS_RELEASE "-O3")#可以设定优化级别为O3set(DEFAULT_CXX_STANDARD 11) #C++11规范set(OpenCV_DIRD:/opencv/opencv3.4.6/opencv/build/x64/vc15/lib/)find_package(OpenCV REQUIRED)include_directories(${OpenCV_INCLUDE_DIRS})include_directories(${PROJECT_SOURCE_DIR}/DNN/)add_executable(main ${PROJECT_SOURCE_DIR}/main.cpp${PROJECT_SOURCE_DIR}/DNN/dnn.cpp)target_link_libraries(main${OpenCV_LIBS})
10.简易示例2(含)
这个是一个叫做的库,做出来的效果是这样的:
可以以系统通知的形式,横幅通知在屏幕右下方,文字、图标都可以换,有点好玩 。这里我又自己二次封装了一下,注意看函数 。这个文件写的很丑,不过既然是自己写着玩,我也就没管了 。
cmake_minimum_required(VERSION 3.17)project(wintoasttest)add_definitions(-DCOMPILEDWITHC11)include_directories(${PROJECT_SOURCE_DIR}/lib-wintoast/)add_library(wintoastlib STATIC ${PROJECT_SOURCE_DIR}/lib-wintoast/wintoastlib.cpp${PROJECT_SOURCE_DIR}/lib-wintoast/wintoastlib.h)add_library(my_wintoastlib STATIC ${PROJECT_SOURCE_DIR}/sjh/my-wintoast/mywintoast.cpp${PROJECT_SOURCE_DIR}/sjh/my-wintoast/mywintoast.h)add_executable(main main.cpp)add_executable(test test.cpp)add_executable(test2 test2.cpp)target_link_libraries(main ${PROJECT_SOURCE_DIR}/lib-wintoast/wintoastlib.lib)target_link_libraries(test ${PROJECT_SOURCE_DIR}/lib-wintoast/wintoastlib.lib)target_link_libraries(test2 ${PROJECT_SOURCE_DIR}/lib-wintoast/wintoastlib.lib${PROJECT_SOURCE_DIR}/sjh/my-wintoast/my_wintoastlib.lib)
后续将会填充其他函数 。写了六千七百字今晚不想写了 。
我终于平庸 终于化成了
路过你头顶的风
【CMake初级简明教程】–《你头顶的风》