linux c++编译 makefile CMakeLists.txt 万能模板

具体路径 根据自己的修改

CMakeLists.txt

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(psenet-demo)

set(CMAKE_PREFIX_PATH
        /home/ws/libtorch
        /home/ws/opencv/build/opencv2)

find_package(OpenCV REQUIRED)
find_package(Torch REQUIRED)


add_executable(psenet-demo main.cpp clipper.cpp)

target_link_libraries(psenet-demo ${TORCH_LIBRARIES} ${OpenCV_LIBS})
set_property(TARGET psenet-demo PROPERTY CXX_STANDARD 11)

makefile

.PHONY:all clean
 
PATH_BIN=bin
 
all:
	@cd ./$(PATH_BIN) && cmake .. && make
 
clean:
	rm -rf $(PATH_BIN)
	mkdir $(PATH_BIN)

 

 

你可能感兴趣的:(程序员进阶)