CMake - yszheda/wiki GitHub Wiki
- How to specify a compiler in CMake?
- How do you set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER for building Assimp for iOS?
- How to find compiler path automatically in cmake?
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
指定从某一路径中寻找toolchain
set(TOOLCHAIN_ROOT "/opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin/")
set(CMAKE_PROGRAM_PATH "/opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin/")
set(GNU_MACHINE "arm-hisiv300-linux-uclibcgnueabi" CACHE STRING "GNU compiler triple")
# set(CMAKE_C_COMPILER "${TOOLCHAIN_ROOT}${GNU_MACHINE}-gcc")
# set(CMAKE_CXX_COMPILER "${TOOLCHAIN_ROOT}${GNU_MACHINE}-g++")
# set(CMAKE_LINKER "${TOOLCHAIN_ROOT}${GNU_MACHINE}-ld")
# set(CMAKE_AR "${TOOLCHAIN_ROOT}${GNU_MACHINE}-ar")
find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}-gcc)
find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}-g++)
find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}-ld)
find_program(CMAKE_AR NAMES ${GNU_MACHINE}-ar)
add_library(dummy OBJECT <source files>)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -X -r5 -o <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -X -r5 -o <TARGET> <LINK_FLAGS> <OBJECTS>")
- Disable -Werror for one of CMakeLists.txt
- disable -Werror ini configure file
- Quick way to override -Werror flag?
- Tutorial: Managing Compiler Warnings with CMake
- Integrate Clang-Tidy into CMake
- How to detect sse availability in CMake
- https://gitorious.org/vc/vc/blobs/master/cmake/FindSSE.cmake
- https://gitorious.org/vc/vc/blobs/master/cmake/OptimizeForArchitecture.cmake
- https://android.googlesource.com/platform/external/eigen/+/master/CMakeLists.txt
- https://chromium.googlesource.com/external/github.com/google/crc32c/+/1.0.5/CMakeLists.txt
- What do the flags in /proc/cpuinfo mean?
- https://cmake.org/cmake/help/v3.0/command/target_compile_definitions.html
- https://git.networks.imdea.org/nicola_bui/imdeaowl/blob/c1e3a9624be5b74c837a32876b65078482ee3450/cmake/modules/FindSSE.cmake
- https://stackoverflow.com/questions/19981534/cmake-include-directories
- https://stackoverflow.com/questions/6921695/how-can-i-build-a-c-project-with-multiple-interdependent-subdirectories
- https://stackoverflow.com/questions/13703647/how-to-properly-add-include-directories-with-cmake
- https://cmake.org/cmake/help/latest/command/target_compile_definitions.html
- cmake的四个命令:add_compile_options、add_definitions、target_compile_definitions、build_command
- CMake Cross Compiling
- CMake设置arm-linux-gcc交叉编译器
- CMake交叉编译配置
- https://stackoverflow.com/questions/12844772/how-to-cross-compile-cmake-for-arm-with-cmake
- https://stackoverflow.com/questions/29677974/cmake-cross-compiling-gnu-tools
- CMake交叉编译
- CMake交叉编译
- What is cmake equivalent of 'configure --prefix=DIR && make all install '?
- How to use CMAKE_INSTALL_PREFIX
- https://cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html
cmake_minimum_required(VERSION 2.8)
project(foo)
install(
DIRECTORY
"./src"
DESTINATION
"include/foo"
FILES_MATCHING
PATTERN
"*.hpp"
)
- CMake compare to empty string with STREQUAL failed
- CMAKE string comparison fails
- If value not equal in cmake 2.8
- https://cmake.org/cmake/help/latest/command/get_filename_component.html
- https://gist.github.com/abravalheri/11214134
- Get target filename without extension with CMake
get_filename_component(lib_we ${lib_loc} NAME_WE)
mkdir Release
cd Release
cmake -DCMAKE_BUILD_TYPE=Release ..
make
mkdir Debug
cd Debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
1. Release: `-O3 -DNDEBUG`
2. Debug: `-O0 -g`
3. RelWithDebInfo: `-O2 -g -DNDEBUG`
4. MinSizeRel: `-Os -DNDEBUG`
-
Change default value of CMAKE_CXX_FLAGS_DEBUG and friends in CMake
-
[Cmake] Setting different compiler flags for Debug vs Release builds
-
https://devtalk.nvidia.com/default/topic/970117/how-to-using-cmake/
LIST(APPEND CUDA_NVCC_FLAGS_RELEASE -DNDEBUG )
LIST(APPEND CUDA_NVCC_FLAGS_RELEASE -O3 )
LIST(APPEND CUDA_NVCC_FLAGS_RELEASE --use_fast_math )
- https://cmake.org/cmake/help/v3.12/command/add_compile_options.html
- Difference between add_compile_options and SET(CMAKE_CXX_FLAGS…)
- https://cmake.org/cmake/help/v3.0/prop_tgt/LIBRARY_OUTPUT_NAME.html
- How do you rename a library filename in CMake?
list(REMOVE_ITEM <list> <value> [<value> ...])
list(FILTER <list> <INCLUDE|EXCLUDE> REGEX <regular_expression>)
file(GLOB helloworld_SRC
"*.h"
"*.cpp"
)
add_executable(helloworld ${helloworld_SRC})
- [CMake] list subdirectories from a given folder
- https://cmake.org/cmake/help/latest/command/subdirs.html
- CMake : How to get the name of all subdirectories of a directory?
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child} AND EXISTS ${curdir}/${child}/CMakeLists.txt)
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
SUBDIRLIST(SUBDIRS ${MY_CURRENT_DIR})
FOREACH(subdir ${SUBDIRS})
ADD_SUBDIRECTORY(${subdir})
ENDFOREACH()
- Building Cross-Platform CUDA Applications with CMake
- cuda_runtime.h error without even including it
- How to let cmake find CUDA
- Building CUDA object files using cmake
- https://cmake.org/cmake/help/v3.0/module/FindCUDA.html
- How to build CUDA programs using CMake
- CMake: how to add cuda to existing project
# CMakeLists.txt for G4CU project
project(test-cuda-thrust-gdb)
# required cmake version
cmake_minimum_required(VERSION 2.8)
# packages
find_package(CUDA)
# nvcc flags
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_20,code=sm_20)
cuda_compile(HELPER_O helper.cu)
cuda_compile(DRIVER_O driver.cu OPTIONS -G)
cuda_add_executable(driver ${HELPER_O} ${DRIVER_O})
- CMake Linking Path
- Crosscompiling with cmake for ARM with OpenCV
- OpenCV with hard-float support for Android
-
CMake: How to run a add_custom_command before everything else
-
CMake: dependencies between targets and files and custom commands
-
https://gist.github.com/baiwfg2/39881ba703e9c74e95366ed422641609
-
https://cmake.org/cmake/help/v2.8.8/cmake.html#command%3aset_directory_properties
-
https://cmake.org/cmake/help/latest/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.html
- https://cmake.org/cmake/help/v3.15/module/FindPkgConfig.html
- What is the proper way to use
pkg-config
fromcmake
? - set PKG_CONFIG_PATH in cmake
- https://cmake.org/cmake/help/v3.3/prop_sf/OBJECT_OUTPUTS.html
- Different compile flags for same file in different targets
- Creating multiple objects from a single source file using cmake
-
https://cmake.org/cmake/help/v2.8.10/cmake.html#prop_tgt%3aCOMPILE_DEFINITIONS
-
https://cmake.org/cmake/help/v2.8.10/cmake.html#command%3aset_target_properties
SET_TARGET_PROPERTIES(name PROPERTIES PREFIX "")
install(TARGETS
your_target
EXPORT YourPackageConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
export(TARGETS
your_target
NAMESPACE YourPackage::
FILE "${CMAKE_CURRENT_BINARY_DIR}/YourPackageConfig.cmake"
)
install(EXPORT
YourPackageConfig
DESTINATION "${CMAKE_INSTALL_DATADIR}/YourPackage/cmake"
NAMESPACE YourPackage::
)
-
https://cmake.org/cmake/help/latest/command/enable_language.html
-
https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/languages/Assembler
-
https://wiki.osdev.org/CMake_Build_System#Building_Assembly_Code
project(XXX LANGUAGES NONE)
set_property(GLOBAL PROPERTY source_list_property "${source_list}")
get_property(source_list GLOBAL PROPERTY source_list_property)
- https://cmake.org/cmake/help/latest/command/cmake_parse_arguments.html
- cmake学习之- cmake_parse_arguments
- More Modern CMake - Functions in CMake
- Calling a CMake function: number of arguments
- CMake macro : how to iterate over arguments
- cmake_parse_arguments storing empty strings
-
Use full path of library
-
How to add libraries with relative path via TARGET_LINK_LIBRARIES?
-
CMake: Convert relative path to absolute path, with build directory as current directory
-
How do I tell CMake to link in a static library in the source directory?
- set_target_properties called with incorrect number of arguments?
- Error “set_target_properties called with incorrect number of arguments” when building Blender as Python module on Mac OS X
SET(CUDA_PROPAGATE_HOST_FLAGS OFF)
- https://github.com/ComputationalRadiationPhysics/alpaka/pull/189
- nvcc fatal : redefinition of argument 'compiler-bindir'
set_target_properties(my_target
PROPERTIES
NO_SYSTEM_FROM_IMPORTED ON
)
- https://cmake.org/cmake/help/v3.0/prop_tgt/NO_SYSTEM_FROM_IMPORTED.html
- [CMake] Making CMake not use -isystem at all
// TODO
CMake Error at CMakeLists.txt: (target_link_libraries):
The plain signature for target_link_libraries has already been used with
the target "". All uses of target_link_libraries with
a target must be either all-keyword or all-plain.
CMake Error at /arm/tools/gnu/cmake/3.14.3/share/cmake-3.14/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
is not able to compile a simple test program.
set(CMAKE_C_COMPILER_WORKS 1)
-
set(_my_text "A B C")
withmessage("${_my_text}")
would give A B C -
set(_my_list A B C)
withmessage("${_my_list}")
would give A;B;C -
set(_my_list "A" "B" "C")
withmessage("${_my_list}")
would give A;B;C -
set(_my_list "A" "B" "C")
withmessage(${_my_list})
would give ABC
- CMake unable to determine linker language with C++
- How do I add objects with a custom extension to a cmake library?
- CMake Error: CMake can not determine linker language for target: myapp
- How to add in a CMake project a global file extension (*.pde) to GCC which is treated like C++ code
set_source_files_properties(${SOURCE} PROPERTIES LANGUAGE CXX)
set(CMAKE_C_OUTPUT_EXTENSION ".rel")
set(CMAKE_CXX_OUTPUT_EXTENSION ".rel")