cmake 從入門到放棄

    以前在Linux下看過一些auto make 工具生成的Makefile,感覺生成的Makefile有一個原則,就是死命讓人看不懂,顯得很高深莫測,我不甘心,一些網友又給我推薦cmake,搜索一下果然是吹的神乎其技,並且說大型工程,自己手工寫Makefile的人就是SB。於是我就整起來,開始在windows下整,遇到一些問題始終很奇怪,解決不了,於是還是在ubuntu下來搞吧。

        sudo apt-get install cmake 安裝即可

    於是隨便整一個只有main 函數的一個c文件,修改 CMakeLists.txt進行編譯,提示No CMAKE_CXX_COMPILER could be found

通過:

sudo apt-get update

sudo apt-get install -y build-essential

解決了,cmake 後生成了Makefile ,執行make 也能生成可執行文件,不過打開Makefile一看,我的神啊,就一個main 函數,居然生成這麼多。。。。。。

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.5

# Default target executed when no arguments are given to make.
default_target: all

.PHONY : default_target

# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:


#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canonical targets will work.
.SUFFIXES:


# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =

.SUFFIXES: .hpux_make_needs_suffix_list


# Suppress display of executed commands.
$(VERBOSE).SILENT:


# A target that is always out of date.
cmake_force:

.PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake

# The command to remove a file.
RM = /usr/bin/cmake -E remove -f

# Escaping for special characters.
EQUALS = =

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/gooogleman/test/test_code/cmake_test

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/gooogleman/test/test_code/cmake_test/build

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target rebuild_cache
rebuild_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
	/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache

.PHONY : rebuild_cache/fast

# Special rule for the target edit_cache
edit_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
	/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
.PHONY : edit_cache

# Special rule for the target edit_cache
edit_cache/fast: edit_cache

.PHONY : edit_cache/fast

# The main all target
all: cmake_check_build_system
	$(CMAKE_COMMAND) -E cmake_progress_start /home/gooogleman/test/test_code/cmake_test/build/CMakeFiles /home/gooogleman/test/test_code/cmake_test/build/CMakeFiles/progress.marks
	$(MAKE) -f CMakeFiles/Makefile2 all
	$(CMAKE_COMMAND) -E cmake_progress_start /home/gooogleman/test/test_code/cmake_test/build/CMakeFiles 0
.PHONY : all

# The main clean target
clean:
	$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean

# The main clean target
clean/fast: clean

.PHONY : clean/fast

# Prepare targets for installation.
preinstall: all
	$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall

# Prepare targets for installation.
preinstall/fast:
	$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast

# clear depends
depend:
	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend

#=============================================================================
# Target rules for targets named cmake_test

# Build rule for target.
cmake_test: cmake_check_build_system
	$(MAKE) -f CMakeFiles/Makefile2 cmake_test
.PHONY : cmake_test

# fast build rule for target.
cmake_test/fast:
	$(MAKE) -f CMakeFiles/cmake_test.dir/build.make CMakeFiles/cmake_test.dir/build
.PHONY : cmake_test/fast

align.o: align.c.o

.PHONY : align.o

# target to build an object file
align.c.o:
	$(MAKE) -f CMakeFiles/cmake_test.dir/build.make CMakeFiles/cmake_test.dir/align.c.o
.PHONY : align.c.o

align.i: align.c.i

.PHONY : align.i

# target to preprocess a source file
align.c.i:
	$(MAKE) -f CMakeFiles/cmake_test.dir/build.make CMakeFiles/cmake_test.dir/align.c.i
.PHONY : align.c.i

align.s: align.c.s

.PHONY : align.s

# target to generate assembly for a file
align.c.s:
	$(MAKE) -f CMakeFiles/cmake_test.dir/build.make CMakeFiles/cmake_test.dir/align.c.s
.PHONY : align.c.s

# Help Target
help:
	@echo "The following are some of the valid targets for this Makefile:"
	@echo "... all (the default if no target is provided)"
	@echo "... clean"
	@echo "... depend"
	@echo "... rebuild_cache"
	@echo "... edit_cache"
	@echo "... cmake_test"
	@echo "... align.o"
	@echo "... align.i"
	@echo "... align.s"
.PHONY : help



#=============================================================================
# Special targets to cleanup operation of make.

# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

        過於複雜,要知道Linux 這麼大的代碼,也是沒這麼晦澀的,也不智能,不能用,放棄!看來還是自己老老實實寫Makefile改善,寫好框架就簡單了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章