Skip to content

Commit

Permalink
scripts: minor fixes on cmake (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Tao authored and qinzuoyan committed Sep 29, 2018
1 parent ca2b88e commit 0b6b42d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
.matchfile
.kdev4/
.zk_install/
.idea

gcov_report/
bin/Linux/thrift
builder/
install/
test_reports/
Dockerfile
include/thrift/
include/dsn/git_commit.h
DSN_ROOT

rdsn.github.config
rdsn.github.creator
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
58 changes: 25 additions & 33 deletions bin/dsn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ""))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 "")
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ add_library(dsn_runtime STATIC
$<TARGET_OBJECTS:dsn.tools.simulator>
$<TARGET_OBJECTS:dsn.tools.http>
)
install(TARGETS dsn_runtime DESTINATION "lib")
10 changes: 5 additions & 5 deletions thirdparty/download-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0b6b42d

Please sign in to comment.