Make and Cmake

1. Make

1.1. Some Symbols

$@ means the target file

$^ means all the dependences

$< means the first dependence

$? means the dependences newer than the target file

2. Cmake

2.1. Libtorch

The CmakeLists.txt is as follow.

1
2
3
4
5
6
7
8
9
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(custom_ops)

set(CMAKE_CUDA_COMPILER /opt/cuda/bin/nvcc)
find_package(Torch REQUIRED)

add_executable(example-app example-app.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
set_property(TARGET example-app PROPERTY CXX_STANDARD 17)

It will use /usr/bin/gcc and /usr/bin/g++ to compile the source files. When I add

1
2
set(CMAKE_C_COMPILER /usr/bin/gcc-13)
set(CMAKE_CXX_COMPILER /usr/bin/g++-13)

into the CmakeLists.txt, it reports The C compiler identification is GNU 13.3.0. However, it also use /usr/bin/gcc and /usr/bin/g++ to compile the source files. Only if i rm /usr/bin/g++, and ln -s /usr/bin/g++-13 /usr/bin/g++, it will use g++13.

The path of standard include directory for g++ is embeded in the binary file of g++, and it has nothing with CmakeLists.txt.