diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a2b9ac..9923de5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,3 +17,6 @@ SET(INCLUDE_INSTALL "include/osmpbf") SET(files ${CMAKE_SOURCE_DIR}/include/osmpbf/osmpbf.h ${CMAKE_BINARY_DIR}/src/osmformat.pb.h ${CMAKE_BINARY_DIR}/src/fileformat.pb.h) INSTALL(FILES ${files} DESTINATION ${INCLUDE_INSTALL}) install(TARGETS osmpbf LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + +configure_file("OsmpbfConfig.cmake.in" "OsmpbfConfig.cmake" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/OsmpbfConfig.cmake" DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/Osmpbf/) diff --git a/src/Makefile b/src/Makefile index f2e053c..3590704 100644 --- a/src/Makefile +++ b/src/Makefile @@ -13,7 +13,7 @@ CXXFLAGS += -Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -W .PHONY: clean install -all: libosmpbf.a libosmpbf.so ../include/osmpbf/fileformat.pb.h ../include/osmpbf/osmformat.pb.h +all: libosmpbf.a libosmpbf.so ../include/osmpbf/fileformat.pb.h ../include/osmpbf/osmformat.pb.h OsmpbfConfig.cmake libosmpbf.a: fileformat.pb.o osmformat.pb.o $(AR) -cr $@ fileformat.pb.o osmformat.pb.o @@ -28,6 +28,12 @@ libosmpbf.so: fileformat.pb.o osmformat.pb.o $(PROTOC) --proto_path=. --cpp_out=. $< cp -v $(subst .proto,.pb.h,$<) ../include/osmpbf/ +%: %.in + # The placeholder for the installation prefix is '@CMAKE_INSTALL_PREFIX@'. + # Do not change that, it would only make the CMakeLists.txt file which does + # the same job as below line more complex. + sed -e 's!@CMAKE_INSTALL_PREFIX@!'$(DESTDIR)$(PREFIX)'!g' <$< >$@ + install: install -m 755 -d $(DESTDIR)$(LIBDIR) install -m 644 libosmpbf.a $(DESTDIR)$(LIBDIR) @@ -38,7 +44,9 @@ install: install -m 644 ../include/osmpbf/osmpbf.h $(DESTDIR)$(PREFIX)/include/osmpbf install -m 644 ../include/osmpbf/fileformat.pb.h $(DESTDIR)$(PREFIX)/include/osmpbf install -m 644 ../include/osmpbf/osmformat.pb.h $(DESTDIR)$(PREFIX)/include/osmpbf + install -m 755 -d $(DESTDIR)$(PREFIX)/lib/cmake/Osmpbf + install -m 644 OsmpbfConfig.cmake $(DESTDIR)$(PREFIX)/lib/cmake/Osmpbf clean: - rm -f *.pb.h *.pb.cc *.pb.o libosmpbf.a + rm -f *.pb.h *.pb.cc *.pb.o libosmpbf.a OsmpbfConfig.cmake diff --git a/src/OsmpbfConfig.cmake.in b/src/OsmpbfConfig.cmake.in new file mode 100644 index 0000000..e6b00ec --- /dev/null +++ b/src/OsmpbfConfig.cmake.in @@ -0,0 +1,2 @@ +set(OSMPBF_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/osmpbf") +set(OSMPBF_LIBRARIES "@CMAKE_INSTALL_PREFIX@/lib/libosmpbf.a")