Last active
September 20, 2019 17:50
-
-
Save raytroop/0476fe128543d423f3fb3be631daef19 to your computer and use it in GitHub Desktop.
CMakeLists Templates
This file contains hidden or 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
This page intentionally left blank |
This file contains hidden or 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
// OpenMP | |
find_package(OpenMP REQUIRED) | |
if(OPENMP_FOUND) | |
message("OPENMP FOUND") | |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | |
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") | |
endif() |
This file contains hidden or 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
// OpenMP & glog/gflags | |
cmake_minimum_required(VERSION 3.12) | |
project(logTUT) | |
set(CMAKE_CXX_STANDARD 11) | |
find_package(glog REQUIRED) | |
find_package(gflags REQUIRED) | |
find_package(OpenMP REQUIRED) | |
add_executable(omprun ompStart.cpp) | |
target_link_libraries(omprun PUBLIC OpenMP::OpenMP_CXX glog::glog) |
This file contains hidden or 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
// googletest | |
cmake_minimum_required(VERSION 3.12) | |
project(gtestTUT) | |
set(CMAKE_CXX_STANDARD 14) | |
INCLUDE_DIRECTORIES(include) | |
AUX_SOURCE_DIRECTORY(src mysrc) | |
# Locate GTest | |
find_package(GTest REQUIRED) | |
include_directories(${GTEST_INCLUDE_DIRS}) | |
# Link runTests with what we want to test and the GTest and pthread library | |
add_executable(runTests ${mysrc}) | |
target_link_libraries(runTests ${GTEST_LIBRARIES} pthread) |
This file contains hidden or 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
// opencv2 | |
# project name | |
PROJECT(opencv_test) | |
# requirement of cmake version | |
cmake_minimum_required(VERSION 3.10) | |
# find required opencv | |
find_package(OpenCV REQUIRED) | |
# name of executable file and path of source file | |
add_executable(opencv_test main.cpp) | |
# opencv libraries | |
target_link_libraries(opencv_test ${OpenCV_LIBS}) | |
# directory of opencv headers | |
target_include_directories(opencv_test PUBLIC ${OpenCV_INCLUDE_DIRS}) |
This file contains hidden or 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
#link_directories(/your/path/to/googletest/lib) | |
#include_directories(/your/path/to/googletest/include) | |
find_library(LibGtest NAMES gtest PATHS /your/path/to/googletest/lib) | |
add_executable(runUnitTests kalman_unittest.cpp) | |
target_link_libraries(runUnitTests ${LibGtest} pthread) | |
target_include_directories(runUnitTests | |
PUBLIC /your/path/to/googletest/include) | |
googletest/ | |
├── include | |
│ ├── gmock | |
│ └── gtest | |
└── lib | |
├── cmake | |
├── libgmock.a | |
├── libgmock_main.a | |
├── libgtest.a | |
├── libgtest_main.a | |
└── pkgconfig |
This file contains hidden or 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.5.1) | |
project(lab2_cpp_calculator) | |
set(CMAKE_CXX_STANDARD 11) | |
#设置find_package的.cmake搜索路径 | |
set(CMAKE_PREFIX_PATH /home/software/Qt5.12.3/5.12.3/gcc_64/lib/cmake) | |
set(CMAKE_AUTOMOC ON) | |
find_package(Qt5Widgets REQUIRED) | |
find_package(Qt5Gui REQUIRED) | |
find_package(Qt5Core REQUIRED) | |
find_package(Qt5OpenGL REQUIRED) | |
set(TARGET lab2_cpp_calculator) | |
set(SOURCE_FILES main.cpp mainwindow.ui mainwindow.cpp mainwindow.h) | |
add_executable(${TARGET} ${SOURCE_FILES}) | |
target_link_libraries(${TARGET} Qt5::Widgets Qt5::Core Qt5::Gui Qt5::OpenGL) | |
target_include_directories(${TARGET} PUBLIC ${CMAKE_SOURCE_DIR}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment