c++ - From Makefile to Cmake -
because of clion release i'd move make cmake. have source folder bunch of .cpp
, .hpp
files , main.cpp
uses classes source above - far had easy makefile compile, link , make exec out of main.cpp
:
c_objs := $(shell find source/*/ -name '*.cpp') sources=source/main.cpp $(c_objs) objects=$(sources:.cpp=.o) executable=bin/main $(executable_t): $(objects_t) $(cc) $(ldflags) $(objects_t) -o $@ $(executable): $(objects) $(cc) $(ldflags) $(objects) -o $@ %.o: %.cpp $(cc) $(cflags) $< -c -o $@ all: $(executable)
in cmake came that:
cmake_minimum_required(version 2.8.4) project(main) #grab file need compile file(glob src "source/*.h" "source/*.hpp" "source/*.cpp" ) #compile .o files need add_library( mylib ${src} ) set(source_files source/main.cpp) #compile .o main.cpp add_executable( main ${source_files} ) #link them target_link_libraries( main mylib )
but keep getting "undefined reference to" classes @ linking , judging compilation time feels not compiled. help? :)
Comments
Post a Comment