Skip to content

Commit 33e6321

Browse files
committed
[examples] improve CMakeLists
1 parent d513065 commit 33e6321

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

examples/CMakeLists.txt

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,35 @@ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${DEBUG_FLAGS}
4242
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
4343
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${DEBUG_FLAGS}")
4444

45-
find_package(Protobuf REQUIRED)
4645
find_package(Threads REQUIRED)
47-
find_package(ZLIB REQUIRED)
4846

49-
include_directories(
50-
${PROTOBUF_INCLUDE_DIRS}
51-
${ZLIB_INCLUDE_DIRS}
52-
${CMAKE_CURRENT_BINARY_DIR}
53-
${CMAKE_CURRENT_SOURCE_DIR}
54-
${CMAKE_SOURCE_DIR}
55-
)
47+
include_directories(${OSMPBF_INCLUDE_DIRS})
5648

57-
set(OSMPBF_LIBRARIES ${osmpbf_BINARY_DIR}/libosmpbf.a)
49+
set(MY_LINK_LIBRARIES
50+
${OSMPBF_LINK_LIBRARIES}
51+
${CMAKE_THREAD_LIBS_INIT}
52+
)
5853

5954
add_executable(dumppbf dumppbf.cpp)
6055
add_dependencies(dumppbf osmpbf)
61-
target_link_libraries(dumppbf ${OSMPBF_LIBRARIES} ${ZLIB_LIBRARIES} ${PROTOBUF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
56+
target_link_libraries(dumppbf )
6257

6358
add_executable(dumppbf_openmp dumppbf.cpp)
6459
add_dependencies(dumppbf_openmp osmpbf)
65-
target_link_libraries(dumppbf_openmp ${OSMPBF_LIBRARIES} ${ZLIB_LIBRARIES} ${PROTOBUF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
60+
target_link_libraries(dumppbf_openmp ${MY_LINK_LIBRARIES})
6661
add_target_properties(dumppbf_openmp COMPILE_FLAGS "-fopenmp")
6762
add_target_properties(dumppbf_openmp LINK_FLAGS "-fopenmp")
6863

6964
add_executable(dumppbf_parsehelpers dumppbf_parsehelpers.cpp)
7065
add_dependencies(dumppbf_parsehelpers osmpbf)
71-
target_link_libraries(dumppbf_parsehelpers ${OSMPBF_LIBRARIES} ${ZLIB_LIBRARIES} ${PROTOBUF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
66+
target_link_libraries(dumppbf_parsehelpers ${MY_LINK_LIBRARIES})
7267
add_target_properties(dumppbf_parsehelpers COMPILE_FLAGS "-fopenmp")
7368
add_target_properties(dumppbf_parsehelpers LINK_FLAGS "-fopenmp")
7469

7570
add_executable(filteredCount filteredCount.cpp)
7671
add_dependencies(filteredCount osmpbf)
77-
target_link_libraries(filteredCount ${OSMPBF_LIBRARIES} ${ZLIB_LIBRARIES} ${PROTOBUF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
72+
target_link_libraries(filteredCount ${MY_LINK_LIBRARIES})
7873

7974
add_executable(osmpbf_dump osmpbf_dump.cpp)
8075
add_dependencies(osmpbf_dump osmpbf)
81-
target_link_libraries(osmpbf_dump ${OSMPBF_LIBRARIES} ${ZLIB_LIBRARIES} ${PROTOBUF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
76+
target_link_libraries(osmpbf_dump ${MY_LINK_LIBRARIES})

0 commit comments

Comments
 (0)