From 3135256204b85a11b118166350201940d19bbb1c Mon Sep 17 00:00:00 2001 From: Igor Eremeev Date: Thu, 28 Dec 2017 20:30:21 +0700 Subject: [PATCH 1/4] Fix whole-archiving for GCC. --- cmake_modules/Commons.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_modules/Commons.cmake b/cmake_modules/Commons.cmake index 1b4db0bf213..847fc7380e8 100644 --- a/cmake_modules/Commons.cmake +++ b/cmake_modules/Commons.cmake @@ -53,7 +53,7 @@ function(set_link_whole target_name lib_name) if (${compiler_id} MATCHES ".*clang") set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS "-Wl,-force_load ${libpath} ") elseif (${compiler_id} STREQUAL "gnu") - set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS "-Wl,--whole-archive ${libpath} ") + set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS "-Wl,--whole-archive ${libpath} -Wl,--no-whole-archive ") elseif (${compiler_id} STREQUAL "msvc") set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS "/WHOLEARCHIVE:${libpath} ") else () From 5502c030ad800cc853b4b802b96c67779e016849 Mon Sep 17 00:00:00 2001 From: Igor Eremeev Date: Fri, 29 Dec 2017 15:36:07 +0700 Subject: [PATCH 2/4] Implement packaging task. --- CMakeLists.txt | 17 +++++++++++++---- README.md | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13b34fff1d9..940b94b759b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${ZLIB_INCLUDE_DIRS} ${includes}) -file(GLOB_RECURSE redex_srcs +file(GLOB_RECURSE redex_lib_srcs "libredex/*.cpp" "libredex/*.h" "opt/*.cpp" @@ -35,7 +35,7 @@ file(GLOB_RECURSE redex_srcs "liblocator/*.h" ) -add_library(redex STATIC ${redex_srcs}) +add_library(redex-lib STATIC ${redex_lib_srcs}) file(GLOB_RECURSE tool_srcs "tools/tool/*.cpp" @@ -62,10 +62,19 @@ target_link_libraries(redex-all ${Boost_LIBRARIES} ${JSONCPP_LIBRARY} ${ZLIB_LIBRARIES} - redex + redex-lib resource ) target_compile_definitions(redex-all PRIVATE) -set_link_whole(redex-all redex) +set_link_whole(redex-all redex-lib) + +add_custom_target(redex + COMMAND ${CMAKE_COMMAND} -E copy $ "${CMAKE_SOURCE_DIR}" + COMMAND "./bundle-redex.sh" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/redex" "${CMAKE_CURRENT_BINARY_DIR}/redex" + DEPENDS redex-all + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Packing redex-all into a bundle..." + ) diff --git a/README.md b/README.md index 0d84daec1f2..8708c454704 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ sudo make install ### Experimental: CMake for Mac, Linux, and Windows -Alternatively, build using CMake. Note that the current `CMakeLists.txt` only implements a rule for `redex-all` binary. We will support installation and testing soon. +Alternatively, build using CMake. Note that the current `CMakeLists.txt` only implements rules for `redex-all` binary and `redex` package. We will support installation and testing soon. Generate build files. By default, it uses Makefile: ``` @@ -103,7 +103,7 @@ cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE="C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake" ``` -Build `redex-all`: +Build `redex-all` and `redex`: ``` cmake --build . From 9941e39d02a8dfb1e3b01b972b0f5e9c2f722755 Mon Sep 17 00:00:00 2001 From: Igor Eremeev Date: Fri, 29 Dec 2017 15:46:59 +0700 Subject: [PATCH 3/4] Add gitignore entry for build folder. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 72dcc7f0d82..d0a209e38b5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /.libs /aclocal.m4 /autom4te.cache +/build /cmd.txt /compile /config.* From bf02cd63fe07cf7766f5b93443788542ef798656 Mon Sep 17 00:00:00 2001 From: Igor Eremeev Date: Thu, 28 Dec 2017 20:30:36 +0700 Subject: [PATCH 4/4] Add missing pthread library --- CMakeLists.txt | 3 ++- cmake_modules/Commons.cmake | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 940b94b759b..ee21dedf5ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.1.0) project("Redex") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) @@ -62,6 +62,7 @@ target_link_libraries(redex-all ${Boost_LIBRARIES} ${JSONCPP_LIBRARY} ${ZLIB_LIBRARIES} + Threads::Threads redex-lib resource ) diff --git a/cmake_modules/Commons.cmake b/cmake_modules/Commons.cmake index 847fc7380e8..c5a74c0e04b 100644 --- a/cmake_modules/Commons.cmake +++ b/cmake_modules/Commons.cmake @@ -44,6 +44,9 @@ macro(add_dependent_packages_for_redex) find_package(ZLIB REQUIRED) print_dirs("${ZLIB_INCLUDE_DIRS}" "ZLIB_INCLUDE_DIRS") print_dirs("${ZLIB_LIBRARIES}" "ZLIB_LIBRARIES") + + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) endmacro() function(set_link_whole target_name lib_name)