Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: add possibility to build zlib from submodule #4778

Merged
merged 2 commits into from
Jun 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()

find_package(ZLIB QUIET)
if (NOT ZLIB_FOUND)
add_subdirectory(3rdparty/zlib EXCLUDE_FROM_ALL)
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/zlib" "${CMAKE_CURRENT_BINARY_DIR}/3rdparty/zlib" CACHE INTERNAL "")
set(ZLIB_LIBRARY zlibstatic)
endif()

# Select the version of libpng to use, default is builtin
if (NOT USE_SYSTEM_LIBPNG)
# We use libpng's static library and don't need to build the shared library and run the tests
Expand Down
8 changes: 5 additions & 3 deletions rpcs3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ if(NOT MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nopie")
endif()
endif()

find_package(ZLIB REQUIRED)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew /D _CRT_SECURE_NO_DEPRECATE=1 /D _CRT_NON_CONFORMING_SWPRINTFS=1 /D _SCL_SECURE_NO_WARNINGS=1")

Expand Down Expand Up @@ -402,6 +400,10 @@ endif()

target_link_libraries(rpcs3 pugixml xxhash yaml-cpp)

find_package(ZLIB REQUIRED)
target_include_directories(rpcs3 PUBLIC ${ZLIB_INCLUDE_DIRS})
target_link_libraries(rpcs3 ${ZLIB_LIBRARIES})

if(WIN32)
target_link_libraries(rpcs3 ws2_32.lib Winmm.lib Psapi.lib gdi32.lib setupapi.lib hidapi-hid Shlwapi.lib)
if(NOT MSVC)
Expand All @@ -421,7 +423,7 @@ else()
else()
target_link_libraries(rpcs3 hidapi-libusb usb)
endif()
target_link_libraries(rpcs3 ${CMAKE_DL_LIBS} ZLIB::ZLIB ${ADDITIONAL_LIBS})
target_link_libraries(rpcs3 ${CMAKE_DL_LIBS} ${ADDITIONAL_LIBS})
if(USE_SYSTEM_FFMPEG)
target_link_libraries(rpcs3 ${FFMPEG_LIBRARIES})
else()
Expand Down