From 0b6b42d045ce34db7159af77fc9defc16323514f Mon Sep 17 00:00:00 2001 From: Wu Tao Date: Sat, 29 Sep 2018 10:37:33 +0800 Subject: [PATCH] scripts: minor fixes on cmake (#166) --- .gitignore | 3 ++ CMakeLists.txt | 9 +++++ bin/dsn.cmake | 58 +++++++++++++------------------ src/core/CMakeLists.txt | 1 + thirdparty/download-thirdparty.sh | 10 +++--- 5 files changed, 43 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 59dccf5681..7ba51908a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ .matchfile .kdev4/ .zk_install/ +.idea +gcov_report/ bin/Linux/thrift builder/ install/ @@ -9,6 +11,7 @@ test_reports/ Dockerfile include/thrift/ include/dsn/git_commit.h +DSN_ROOT rdsn.github.config rdsn.github.creator diff --git a/CMakeLists.txt b/CMakeLists.txt index f85f4b79bc..82e3150112 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,16 @@ if(ENABLE_GCOV) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") endif() +# Users don't have to configure CMAKE_INSTALL_PREFIX unless they want to customize +# the destination. +set(CMAKE_INSTALL_PREFIX ${DSN_ROOT} CACHE STRING "" FORCE) +message (STATUS "dsn Installation directory: CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) + # install rdsn/include to ${CMAKE_INCLUDE_PREFIX}/include install(DIRECTORY include/ DESTINATION include) +include_directories(${DSN_PROJECT_DIR}/include) +include_directories(${DSN_PROJECT_DIR}/include/dsn/cpp/serialization_helper) +include_directories(${DSN_PROJECT_DIR}/src) + add_subdirectory(src) diff --git a/bin/dsn.cmake b/bin/dsn.cmake index 8c1944ea34..562b91caab 100644 --- a/bin/dsn.cmake +++ b/bin/dsn.cmake @@ -7,20 +7,18 @@ include(${CMAKE_CURRENT_LIST_DIR}/compiler_info.cmake) set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) -# Set DSN_ROOT to ${PROJECT_BINARY_DIR}/output, this is where targets will be installed. -# Users don't have to configure CMAKE_INSTALL_PREFIX unless they want to customize -# the destination. -set(DSN_ROOT ${PROJECT_BINARY_DIR}/output) -message(STATUS "DSN_ROOT = ${DSN_ROOT}") -set(CMAKE_INSTALL_PREFIX ${DSN_ROOT} CACHE STRING "" FORCE) -message (STATUS "Installation directory: CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) +# Set DSN_PROJECT_DIR to rdsn/ +set(DSN_PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR}) +get_filename_component(DSN_PROJECT_DIR ${DSN_PROJECT_DIR} DIRECTORY) -# Set DSN_THIRDPARTY_ROOT to rdsn/thirdparty -set(RDSN_PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR}) -get_filename_component(RDSN_PROJECT_DIR ${RDSN_PROJECT_DIR} DIRECTORY) -set(DSN_THIRDPARTY_ROOT ${RDSN_PROJECT_DIR}/thirdparty) +# Set DSN_THIRDPARTY_ROOT to rdsn/thirdparty/output +set(DSN_THIRDPARTY_ROOT ${DSN_PROJECT_DIR}/thirdparty/output) message(STATUS "DSN_THIRDPARTY_ROOT = ${DSN_THIRDPARTY_ROOT}") +# Set DSN_ROOT to rdsn/DSN_ROOT, this is where rdsn will be installed +set(DSN_ROOT ${DSN_PROJECT_DIR}/DSN_ROOT) +message(STATUS "DSN_ROOT = ${DSN_ROOT}") + # Install this target into ${CMAKE_INSTALL_PREFIX}/lib function(dsn_install_library) @@ -85,9 +83,11 @@ endfunction(ms_add_project) # "GLOB_RECURSE" for recursive search # "GLOB" for non-recursive search # - MY_PROJ_SRC -# - MY_PROJ_INC_PATH +# - MY_PROJ_INC_PATH TODO(wutao1): remove this # - MY_PROJ_LIB_PATH TODO(wutao1): remove this +# - MY_PROJ_LIBS # - MY_BINPLACES +# Extra files that will be installed # - MY_BOOST_PACKAGES function(dsn_add_project) if((NOT DEFINED MY_PROJ_TYPE) OR (MY_PROJ_TYPE STREQUAL "")) @@ -198,10 +198,16 @@ function(dsn_setup_compiler_flags) endif() cmake_host_system_information(RESULT BUILD_HOSTNAME QUERY HOSTNAME) add_definitions(-DDSN_BUILD_HOSTNAME=${BUILD_HOSTNAME}) + + # We want access to the PRI* print format macros. add_definitions(-D__STDC_FORMAT_MACROS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y" CACHE STRING "" FORCE) + + # -Wall: Enable all warnings. add_compile_options(-Wall) add_compile_options(-Werror) + # -Wno-sign-compare: suppress warnings for comparison between signed and unsigned integers add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-strict-aliasing) add_compile_options(-Wuninitialized) @@ -254,7 +260,7 @@ macro(ms_setup_boost STATIC_LINK PACKAGES BOOST_LIBS) endmacro(ms_setup_boost) # find necessary system libs -function(dsn_setup_packages) +function(dsn_setup_system_libs) find_package(Threads REQUIRED) set(DSN_SYSTEM_LIBS "") @@ -277,7 +283,7 @@ function(dsn_setup_packages) endif() set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_DL}) - # TODO(wutao1): maybe we do not need this? + # for md5 calculation find_library(DSN_LIB_CRYPTO NAMES crypto) if(DSN_LIB_CRYPTO STREQUAL "DSN_LIB_CRYPTO-NOTFOUND") message(FATAL_ERROR "Cannot find library crypto") @@ -289,33 +295,19 @@ function(dsn_setup_packages) ${CMAKE_THREAD_LIBS_INIT} # the thread library found by FindThreads CACHE STRING "rDSN system libs" FORCE ) -endfunction(dsn_setup_packages) +endfunction(dsn_setup_system_libs) function(dsn_setup_include_path) if(DEFINED BOOST_ROOT) include_directories(${BOOST_ROOT}/include) endif() include_directories(${BOOST_INCLUDEDIR}) - if(DSN_BUILD_RUNTIME) - include_directories(${CMAKE_SOURCE_DIR}/include) - include_directories(${CMAKE_SOURCE_DIR}/include/dsn/cpp/serialization_helper) - include_directories(${CMAKE_SOURCE_DIR}/src) - include_directories(${CMAKE_SOURCE_DIR}/thirdparty/output/include) - else() - include_directories(${DSN_ROOT}/include) - include_directories(${DSN_ROOT}/include/dsn/cpp/serialization_helper) - include_directories(${DSN_THIRDPARTY_ROOT}/include) - endif() + include_directories(${DSN_THIRDPARTY_ROOT}/include) endfunction(dsn_setup_include_path) function(dsn_setup_link_path) - link_directories(${BOOST_LIBRARYDIR} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) - if(DSN_BUILD_RUNTIME) - link_directories(${CMAKE_SOURCE_DIR}/thirdparty/output/lib) - else() - link_directories(${DSN_ROOT}/lib) - link_directories(${DSN_THIRDPARTY_ROOT}/lib) - endif() + link_directories(${BOOST_LIBRARYDIR}) + link_directories(${DSN_THIRDPARTY_ROOT}/lib) endfunction(dsn_setup_link_path) function(dsn_common_setup) @@ -341,7 +333,7 @@ function(dsn_common_setup) message(FATAL_ERROR "You need a compiler with C++1y support.") endif() - dsn_setup_packages() + dsn_setup_system_libs() dsn_setup_compiler_flags() dsn_setup_include_path() dsn_setup_link_path() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4e6904563b..5bdef1017d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -13,3 +13,4 @@ add_library(dsn_runtime STATIC $ $ ) +install(TARGETS dsn_runtime DESTINATION "lib") diff --git a/thirdparty/download-thirdparty.sh b/thirdparty/download-thirdparty.sh index 207210ab20..f0b7166f1e 100755 --- a/thirdparty/download-thirdparty.sh +++ b/thirdparty/download-thirdparty.sh @@ -197,16 +197,16 @@ check_and_download "gflags-2.2.1.zip"\ exit_if_fail $? # s2geometry -check_and_download "s2geometry-master.zip"\ - "https://github.com/google/s2geometry/archive/master.zip"\ - "afda53fb79131248d414e10f5246f4ed"\ - "s2geometry-master" +check_and_download "s2geometry-0239455c1e260d6d2c843649385b4fb9f5b28dba.zip"\ + "https://github.com/google/s2geometry/archive/0239455c1e260d6d2c843649385b4fb9f5b28dba.zip"\ + "bfa5f1c08f535a72fb2c92ec16332c64"\ + "s2geometry-0239455c1e260d6d2c843649385b4fb9f5b28dba" ret_code=$? if [ $ret_code -eq 2 ]; then exit 2 elif [ $ret_code -eq 0 ]; then echo "make patch to s2geometry" - cd s2geometry-master + cd s2geometry-0239455c1e260d6d2c843649385b4fb9f5b28dba patch -p1 < ../../fix_s2_for_pegasus.patch if [ $? != 0 ]; then echo "ERROR: patch fix_s2_for_pegasus.patch for s2geometry failed"