Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        4年前关闭。
                                                                                            
                
        
我想问一下如何将Makefile转换为CMAKEList。目前,我可以编译CMAKEList。但是,该程序的行为与Makefile程序生成的程序不同。

细节:
1.这是我的Makefile



#===========================================================================
# Makefile for behavior_program
#---------------------------------------------------------------------------
# [Update log]
#===========================================================================

TARGET	= PFforAEV0.2.2
CC	= g++
SYSTEM	= linux
LIB_DIR	= -L/usr/local/lib
#LIBS    = -lglut -lGLU -lGL -lm -lX11 -lXi -L/usr/X11R6/lib -lpthread -lSSM
LIBS    =  -lm  -L/usr/X11R6/lib -L/usr/local/lib64 -lpthread -lSSM
INCDIR	= -I./include -I/usr/local/include

#DEBUG
CPPFLAGS= -O3 -Wall  $(INCDIR)

#COMPLETE
#CFLAGS	= -O2 -g -Wall -Werror -Wmissing-prototypes $(INCDIR)

OBJS = primitives.o PFforAEV.o motion_vw.o observation_lrf.o particle_filter.o gnuplot2D.o

all:	$(SYSTEM)

linux:	$(OBJS)
	$(CC) $(OBJS) $(LIB_DIR) $(LIBS) -o $(TARGET)
	rm -f  *.o *~ defs/*~ core

clean:
	rm -f $(TARGET) *.o *~ defs/*~ core

install:
	cp $(TARGET) ../../bin






这是我的CMAKEList




cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(PFforAEV0.2.2)
include_directories( -I./include -I/usr/local/include)
include_directories(-I./include -I/usr/local/include)

add_executable(PFforAEV0.2.2   primitives.cpp PFforAEV.cpp motion_vw.cpp
observation_lrf.cpp particle_filter.cpp gnuplot2D.cpp)

target_link_libraries (PFforAEV0.2.2  -lm  -L/usr/X11R6/lib -L/usr/local/lib64 -lpthread -lSSM  -L/usr/local/lib)

set(CMAKE_CXX_FLAGS " -Wall -I./include -I/usr/local/include ")

最佳答案

快速浏览,您的编译标志并不相同。

例如,在Makefile中

CPPFLAGS= -O3 -Wall  $(INCDIR)


但是,在CMakeLists.txt中,

set(CMAKE_CXX_FLAGS " -Wall -I./include -I/usr/local/include ")


缺少“ -O3”标志。

确保标志相同。

链接库也是如此。

10-05 23:45