From 17ea24cdb08648724a8f3e2f34f83cc6a50aef3e Mon Sep 17 00:00:00 2001 From: James Benton Date: Fri, 25 May 2018 13:54:17 +0100 Subject: [PATCH] Add zlib as a submodule. --- .gitmodules | 3 +++ tools/CMakeLists.txt | 1 - tools/elf2rpl/CMakeLists.txt | 5 +---- tools/libraries/CMakeLists.txt | 15 +++++++++++++++ tools/libraries/zlib | 1 + tools/readrpl/CMakeLists.txt | 5 +---- tools/rplgen/CMakeLists.txt | 5 +---- 7 files changed, 22 insertions(+), 13 deletions(-) create mode 160000 tools/libraries/zlib diff --git a/.gitmodules b/.gitmodules index 30d0af8..61e5bcd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "tools/libraries/excmd"] path = tools/libraries/excmd url = https://github.com/exjam/excmd.git +[submodule "tools/libraries/zlib"] + path = tools/libraries/zlib + url = https://github.com/madler/zlib.git diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 35dc3f4..7831975 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -14,7 +14,6 @@ else() endif() add_subdirectory(libraries) -find_package(ZLIB REQUIRED) include_directories(common) add_subdirectory(elf2rpl) diff --git a/tools/elf2rpl/CMakeLists.txt b/tools/elf2rpl/CMakeLists.txt index f7a46a6..f435a3a 100644 --- a/tools/elf2rpl/CMakeLists.txt +++ b/tools/elf2rpl/CMakeLists.txt @@ -6,11 +6,8 @@ file(GLOB_RECURSE HEADER_FILES *.h) add_executable(elf2rpl ${SOURCE_FILES} ${HEADER_FILES}) -target_include_directories(elf2rpl PRIVATE - ${ZLIB_INCLUDE_DIR}) - target_link_libraries(elf2rpl fmt - ${ZLIB_LIBRARIES}) + zlib) install(TARGETS elf2rpl RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/tools/libraries/CMakeLists.txt b/tools/libraries/CMakeLists.txt index 7d170a9..ea1a098 100644 --- a/tools/libraries/CMakeLists.txt +++ b/tools/libraries/CMakeLists.txt @@ -4,3 +4,18 @@ target_include_directories(excmd INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/excmd/sr # fmt add_subdirectory(fmt) + +# zlib +find_package(ZLIB QUIET) + +if(NOT ZLIB_FOUND) + add_subdirectory(zlib) + + target_include_directories(zlib INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/zlib" + "${CMAKE_CURRENT_BINARY_DIR}/zlib") +else() + add_library(zlib INTERFACE) + target_link_libraries(zlib INTERFACE ${ZLIB_LIBRARIES}) + target_include_directories(zlib INTERFACE ${ZLIB_INCLUDE_DIR}) +endif() diff --git a/tools/libraries/zlib b/tools/libraries/zlib new file mode 160000 index 0000000..cacf7f1 --- /dev/null +++ b/tools/libraries/zlib @@ -0,0 +1 @@ +Subproject commit cacf7f1d4e3d44d871b605da3b647f07d718623f diff --git a/tools/readrpl/CMakeLists.txt b/tools/readrpl/CMakeLists.txt index 9d2ade2..b2e5599 100644 --- a/tools/readrpl/CMakeLists.txt +++ b/tools/readrpl/CMakeLists.txt @@ -6,12 +6,9 @@ file(GLOB_RECURSE HEADER_FILES *.h) add_executable(readrpl ${SOURCE_FILES} ${HEADER_FILES}) -target_include_directories(readrpl PRIVATE - ${ZLIB_INCLUDE_DIR}) - target_link_libraries(readrpl excmd fmt - ${ZLIB_LIBRARIES}) + zlib) install(TARGETS readrpl RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/tools/rplgen/CMakeLists.txt b/tools/rplgen/CMakeLists.txt index 3545b7f..243b173 100644 --- a/tools/rplgen/CMakeLists.txt +++ b/tools/rplgen/CMakeLists.txt @@ -6,10 +6,7 @@ file(GLOB_RECURSE HEADER_FILES *.h) add_executable(rplgen ${SOURCE_FILES} ${HEADER_FILES}) -target_include_directories(rplgen PRIVATE - ${ZLIB_INCLUDE_DIR}) - target_link_libraries(rplgen - ${ZLIB_LIBRARIES}) + zlib) install(TARGETS rplgen RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")