From 74b99567bb8e2b7c0e65e1533a0b7f4416102fe3 Mon Sep 17 00:00:00 2001 From: guihao_liang Date: Mon, 23 Mar 2020 17:22:09 -0700 Subject: [PATCH 1/3] make 0045 0046 new --- cmake/MakeLibrary.cmake | 257 +++++++++++++----------- deps/cmake/ExternalProjectLibXML2.cmake | 7 +- deps/cmake/ExternalProjectOpenSSL.cmake | 22 +- 3 files changed, 152 insertions(+), 134 deletions(-) diff --git a/cmake/MakeLibrary.cmake b/cmake/MakeLibrary.cmake index d8c54b30e3..90232bd1fd 100644 --- a/cmake/MakeLibrary.cmake +++ b/cmake/MakeLibrary.cmake @@ -1,27 +1,29 @@ - -# This is an internal function and should not be used -# Usage: +# This is an internal function and should not be used Usage: # make_target_impl(target compile_flags sources requirements is_library SHARED) # -# Example: -# make_target_impl(fileio "-fPIC" -# "asyncurl.cpp;sysutils.cpp" -# "logger;dl;pthread;z" -# TRUE FALSE) +# Example: make_target_impl(fileio "-fPIC" "asyncurl.cpp;sysutils.cpp" +# "logger;dl;pthread;z" TRUE FALSE) # # This generates a target library/binary with the given name. The optional # compile_flags are appended to the target compile flags. "-fPIC" is ALWAYS -# added for libraries. "sources" is a list listing all the library/binary -# source files. "requirements" is a list listing all the libraries, and -# builtins this target depends on. IS_LIBRARY must be "TRUE" or "FALSE" +# added for libraries. "sources" is a list listing all the library/binary source +# files. "requirements" is a list listing all the libraries, and builtins this +# target depends on. IS_LIBRARY must be "TRUE" or "FALSE" # # if DYNAMIC is true, a dynamic library is built. # -# Boost, pthread is always added as a default dependency. -# when possible. -macro(make_target_impl NAME FLAGS REQUIREMENTS IS_LIBRARY SHARED SHARED_ALL_DEFINED OBJECT) +# Boost, pthread is always added as a default dependency. when possible. +macro( + make_target_impl + NAME + FLAGS + REQUIREMENTS + IS_LIBRARY + SHARED + SHARED_ALL_DEFINED + OBJECT) # create the target - if (${IS_LIBRARY}) + if(${IS_LIBRARY}) message(STATUS "Adding Library: ${NAME}") else() message(STATUS "Adding Executable: ${NAME}") @@ -33,98 +35,93 @@ macro(make_target_impl NAME FLAGS REQUIREMENTS IS_LIBRARY SHARED SHARED_ALL_DEFI # add a custom property to the target listing its dependencies if(NOT ${FLAGS} STREQUAL "") - set_property(TARGET ${NAME} APPEND_STRING PROPERTY COMPILE_FLAGS " ${FLAGS}") + set_property(TARGET ${NAME} APPEND_STRING PROPERTY COMPILE_FLAGS + " ${FLAGS}") endif() - if (${IS_LIBRARY}) - if (NOT WIN32) - #windows is always fPIC + if(${IS_LIBRARY}) + if(NOT WIN32) + # windows is always fPIC set_property(TARGET ${NAME} APPEND_STRING PROPERTY COMPILE_FLAGS " -fPIC") endif() - if (APPLE) - if (${SHARED}) - if (NOT ${SHARED_ALL_DEFINED}) - set_property(TARGET ${NAME} APPEND_STRING PROPERTY LINK_FLAGS " -undefined dynamic_lookup") + if(APPLE) + if(${SHARED}) + if(NOT ${SHARED_ALL_DEFINED}) + set_property(TARGET ${NAME} APPEND_STRING + PROPERTY LINK_FLAGS " -undefined dynamic_lookup") endif() endif() endif() endif() - if (${IS_LIBRARY}) + if(${IS_LIBRARY}) if(${SHARED}) target_link_libraries(${NAME} PRIVATE ${REQUIREMENTS}) elseif(${OBJECT}) # TODO we can link the requirements from here when target_link_libraries - # works with OBJECT library targets (requires CMake 3.12) - # See https://gitlab.kitware.com/cmake/cmake/issues/14778 - # For now, do nothing. + # works with OBJECT library targets (requires CMake 3.12) See + # https://gitlab.kitware.com/cmake/cmake/issues/14778 For now, do nothing. else() target_link_libraries(${NAME} PUBLIC ${REQUIREMENTS}) endif() else() target_link_libraries(${NAME} PUBLIC ${REQUIREMENTS}) endif() - - # Ensure dependencies are tracked in order to make sure compilation order matters. - add_dependencies(${NAME} "${REQUIREMENTS}") - + + # Ensure dependencies are tracked in order to make sure compilation order + # matters. + if (REQUIREMENTS) + add_dependencies(${NAME} ${REQUIREMENTS}) + endif() + # make sure dependencies are always built first - add_dependencies(${NAME} "${_TC_EXTERNAL_DEPENDENCIES}") - add_dependencies(${NAME} external_dependencies) -endmacro() + if (TC_EXTERNAL_DEPENDENCIES) + add_dependencies(${NAME} ${TC_EXTERNAL_DEPENDENCIES}) + endif() + if (external_dependencies) + add_dependencies(${NAME} external_dependencies) + endif() -# This is an external function -# Usage: -# make_library(NAME target -# SOURCES a.cpp b.cpp -# REQUIRES libx liby -# MAC_REQUIRES libz libzz -# LINUX_REQUIRES libk libj -# [SHARED] [OUTPUT_NAME xxxx] [SHARED_ALL_DEFINED] -# [OBJECT] -# ) -# Example: +endmacro() + +# This is an external function Usage: make_library(NAME target SOURCES a.cpp +# b.cpp REQUIRES libx liby MAC_REQUIRES libz libzz LINUX_REQUIRES libk libj +# [SHARED] [OUTPUT_NAME xxxx] [SHARED_ALL_DEFINED] [OBJECT] ) Example: # -# make_library(NAME fileio -# SOURCES -# asyncurl.cpp -# sysutils.cpp -# wsconn.cpp -# s3_api.cpp -# hdfs.cpp -# REQUIRES -# logger dl pthread z curl xml2 openssl -# MAC_REQUIRES -# iconv -# ) -# This generates a library with the provided target name. +# make_library(NAME fileio SOURCES asyncurl.cpp sysutils.cpp wsconn.cpp +# s3_api.cpp hdfs.cpp REQUIRES logger dl pthread z curl xml2 openssl +# MAC_REQUIRES iconv ) This generates a library with the provided target name. # -# NAME and SOURCES must be specified. -# REQUIRES lists all dependent libraries. These can be: -# - other libraries built by the the turicreate build system -# - builtin libraries -# - system libraries -# MAC_REQUIRES lists all dependent libraries which are included only on Mac. -# LINUX_REQUIRES lists all dependent libraries which are included only on Linux. -# SHARED will build a shared library instead of a static library -# EXTERNAL_VISIBILITY will make the symbols be publicly visible. Default is hidden -# SHARED_ALL_DEFINED will require shared libraries to have all symbols defined -# OBJECT will build an object library instead of a static library +# NAME and SOURCES must be specified. REQUIRES lists all dependent libraries. +# These can be: - other libraries built by the the turicreate build system - +# builtin libraries - system libraries MAC_REQUIRES lists all dependent +# libraries which are included only on Mac. LINUX_REQUIRES lists all dependent +# libraries which are included only on Linux. SHARED will build a shared library +# instead of a static library EXTERNAL_VISIBILITY will make the symbols be +# publicly visible. Default is hidden SHARED_ALL_DEFINED will require shared +# libraries to have all symbols defined OBJECT will build an object library +# instead of a static library # -# All other targets which depends on this library (using the "requires" function) -# will automatically include all recursive dependencies. +# All other targets which depends on this library (using the "requires" +# function) will automatically include all recursive dependencies. # -# Boost, pthread is always added as a default dependency. -# when possible. +# Boost, pthread is always added as a default dependency. when possible. macro(make_library NAME) set(options SHARED EXTERNAL_VISIBILITY SHARED_ALL_DEFINED DEAD_STRIP OBJECT) - set(one_value_args COMPILE_FLAGS OUTPUT_NAME EXPORT_LINUX_MAP_FILE EXPORT_OSX_MAP_FILE) + set(one_value_args COMPILE_FLAGS OUTPUT_NAME EXPORT_LINUX_MAP_FILE + EXPORT_OSX_MAP_FILE) set(multi_value_args - SOURCES REQUIRES MAC_REQUIRES LINUX_REQUIRES - COMPILE_FLAGS_EXTRA COMPILE_FLAGS_EXTRA_CLANG COMPILE_FLAGS_EXTRA_GCC) - CMAKE_PARSE_ARGUMENTS(make_library "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) + SOURCES + REQUIRES + MAC_REQUIRES + LINUX_REQUIRES + COMPILE_FLAGS_EXTRA + COMPILE_FLAGS_EXTRA_CLANG + COMPILE_FLAGS_EXTRA_GCC) + cmake_parse_arguments(make_library "${options}" "${one_value_args}" + "${multi_value_args}" ${ARGN}) if(NOT make_library_SOURCES) - MESSAGE(FATAL_ERROR "make_library call with no sources") + message(FATAL_ERROR "make_library call with no sources") endif() if(TC_DISABLE_OBJECT_BUILDS) @@ -143,17 +140,19 @@ macro(make_library NAME) endforeach() endif() - if (APPLE) - if (make_library_MAC_REQUIRES) - set(make_library_REQUIRES ${make_library_REQUIRES} ${make_library_MAC_REQUIRES}) + if(APPLE) + if(make_library_MAC_REQUIRES) + set(make_library_REQUIRES ${make_library_REQUIRES} + ${make_library_MAC_REQUIRES}) endif() else() - if (make_library_LINUX_REQUIRES) - set(make_library_REQUIRES ${make_library_REQUIRES} ${make_library_LINUX_REQUIRES}) + if(make_library_LINUX_REQUIRES) + set(make_library_REQUIRES ${make_library_REQUIRES} + ${make_library_LINUX_REQUIRES}) endif() endif() - if (${make_library_SHARED}) + if(${make_library_SHARED}) add_library(${NAME} SHARED ${make_library_SOURCES}) elseif(${make_library_OBJECT}) add_library(${NAME} OBJECT ${make_library_SOURCES}) @@ -161,73 +160,93 @@ macro(make_library NAME) add_library(${NAME} STATIC ${make_library_SOURCES}) endif() - make_target_impl("${NAME}" "${make_library_COMPILE_FLAGS}" - "${make_library_REQUIRES}" TRUE "${make_library_SHARED}" "${make_library_SHARED_ALL_DEFINED}" "${make_library_OBJECT}") + make_target_impl( + "${NAME}" + "${make_library_COMPILE_FLAGS}" + "${make_library_REQUIRES}" + TRUE + "${make_library_SHARED}" + "${make_library_SHARED_ALL_DEFINED}" + "${make_library_OBJECT}") - if (make_library_OUTPUT_NAME) - message(STATUS "make_library ${NAME} ===> ${make_library_OUTPUT_NAME}") - set_target_properties(${NAME} PROPERTIES OUTPUT_NAME ${make_library_OUTPUT_NAME}) + if(make_library_OUTPUT_NAME) + message(STATUS "make_library ${NAME} ===> ${make_library_OUTPUT_NAME}") + set_target_properties(${NAME} PROPERTIES OUTPUT_NAME + ${make_library_OUTPUT_NAME}) endif() - if (make_library_COMPILE_FLAGS_EXTRA) + if(make_library_COMPILE_FLAGS_EXTRA) target_compile_options(${NAME} PRIVATE ${make_library_COMPILE_FLAGS_EXTRA}) endif() - if (CLANG) - if (make_library_COMPILE_FLAGS_EXTRA_CLANG) - target_compile_options(${NAME} PRIVATE ${make_library_COMPILE_FLAGS_EXTRA_CLANG}) + if(CLANG) + if(make_library_COMPILE_FLAGS_EXTRA_CLANG) + target_compile_options(${NAME} + PRIVATE ${make_library_COMPILE_FLAGS_EXTRA_CLANG}) endif() endif() - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (make_library_COMPILE_FLAGS_EXTRA_GCC) - target_compile_options(${NAME} PRIVATE ${make_library_COMPILE_FLAGS_EXTRA_GCC}) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if(make_library_COMPILE_FLAGS_EXTRA_GCC) + target_compile_options(${NAME} + PRIVATE ${make_library_COMPILE_FLAGS_EXTRA_GCC}) endif() endif() - if (${make_library_EXTERNAL_VISIBILITY} OR ${make_library_OBJECT}) + if(${make_library_EXTERNAL_VISIBILITY} OR ${make_library_OBJECT}) # do nothing message(STATUS "External Visibility: " ${NAME}) target_compile_options(${NAME} PRIVATE "-fvisibility=default") - target_compile_options(${NAME} PRIVATE $<$:-fvisibility-inlines-hidden>) + target_compile_options( + ${NAME} PRIVATE $<$:-fvisibility-inlines-hidden>) else() target_compile_options(${NAME} PRIVATE "-fvisibility=hidden") - target_compile_options(${NAME} PRIVATE $<$:-fvisibility-inlines-hidden>) + target_compile_options( + ${NAME} PRIVATE $<$:-fvisibility-inlines-hidden>) endif() if(NOT CLANG) - if (NOT WIN32) - # set_property(TARGET ${NAME} APPEND_STRING PROPERTY LINK_FLAGS " -static-libstdc++ ") + if(NOT WIN32) + # set_property(TARGET ${NAME} APPEND_STRING PROPERTY LINK_FLAGS " -static- + # libstdc++ ") endif() endif() if(APPLE) - if(make_library_EXPORT_OSX_MAP_FILE) - set_property(TARGET ${NAME} APPEND PROPERTY LINK_DEPENDS "${make_library_EXPORT_OSX_MAP_FILE}") - set_property(TARGET ${NAME} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-exported_symbols_list,${make_library_EXPORT_OSX_MAP_FILE} ") - endif() + if(make_library_EXPORT_OSX_MAP_FILE) + set_property(TARGET ${NAME} APPEND + PROPERTY LINK_DEPENDS "${make_library_EXPORT_OSX_MAP_FILE}") + set_property( + TARGET ${NAME} APPEND_STRING + PROPERTY + LINK_FLAGS + " -Wl,-exported_symbols_list,${make_library_EXPORT_OSX_MAP_FILE} ") + endif() - if(make_library_DEAD_STRIP) - set_property(TARGET ${NAME} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-dead_strip") - endif() + if(make_library_DEAD_STRIP) + set_property(TARGET ${NAME} APPEND_STRING PROPERTY LINK_FLAGS + " -Wl,-dead_strip") + endif() -else() - if(make_library_EXPORT_LINUX_MAP_FILE) - set_property(TARGET ${NAME} APPEND PROPERTY LINK_DEPENDS "${make_library_EXPORT_LINUX_MAP_FILE}") - set_property(TARGET ${NAME} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--version-script=${make_library_EXPORT_LINUX_MAP_FILE} ") + else() + if(make_library_EXPORT_LINUX_MAP_FILE) + set_property( + TARGET ${NAME} APPEND PROPERTY LINK_DEPENDS + "${make_library_EXPORT_LINUX_MAP_FILE}") + set_property( + TARGET ${NAME} APPEND_STRING + PROPERTY LINK_FLAGS + " -Wl,--version-script=${make_library_EXPORT_LINUX_MAP_FILE} ") + endif() endif() -endif() endmacro() -# Creates an empty library to use as a dependency placeholder. -# -# Usage: -# make_empty_library(NAME) -# +# Creates an empty library to use as a dependency placeholder. +# +# Usage: make_empty_library(NAME) # # will automatically include all recursive dependencies. macro(make_empty_library NAME) add_library(${NAME} INTERFACE) endmacro() - diff --git a/deps/cmake/ExternalProjectLibXML2.cmake b/deps/cmake/ExternalProjectLibXML2.cmake index 047df3d1c3..e76f2048fa 100644 --- a/deps/cmake/ExternalProjectLibXML2.cmake +++ b/deps/cmake/ExternalProjectLibXML2.cmake @@ -21,7 +21,7 @@ endif() ExternalProject_Add(ex_libxml2 PREFIX ${CMAKE_SOURCE_DIR}/deps/build/libxml2 - URL ${CMAKE_SOURCE_DIR}/deps/src/libxml2-2.9.1/ + URL ${CMAKE_SOURCE_DIR}/deps/src/libxml2-2.9.1/ INSTALL_DIR ${CMAKE_SOURCE_DIR}/deps/local CONFIGURE_COMMAND bash -c "${__SDKCMD} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS=\"${__ARCH_FLAG} ${CMAKE_C_FLAGS} -w -Wno-everything\" /configure --prefix= --enable-shared=no --enable-static=yes --without-lzma --libdir=/lib --with-python=./ ${EXTRA_CONFIGURE_FLAGS}" BUILD_COMMAND cp /testchar.c /testapi.c && ${__SDKCMD} make @@ -30,16 +30,15 @@ ExternalProject_Add(ex_libxml2 # the with-python=./ prevents it from trying to build/install some python stuff # which is poorly installed (always ways to stick it in a system directory) include_directories(${CMAKE_SOURCE_DIR}/deps/local/include/libxml2) -add_dependencies(ex_libxml2 ex_libz) add_library(libxml2a STATIC IMPORTED) set_property(TARGET libxml2a PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/deps/local/lib/libxml2.a) add_library(libxml2 INTERFACE ) add_dependencies(libxml2 ex_libxml2) -target_link_libraries(libxml2 INTERFACE libxml2a z) +target_link_libraries(libxml2 INTERFACE libxml2a) if(WIN32) - target_link_libraries(libxml2 INTERFACE iconv ws2_32 z) + target_link_libraries(libxml2 INTERFACE iconv ws2_32) endif() target_compile_definitions(libxml2 INTERFACE HAS_LIBXML2) set(HAS_LIBXML2 TRUE CACHE BOOL "") diff --git a/deps/cmake/ExternalProjectOpenSSL.cmake b/deps/cmake/ExternalProjectOpenSSL.cmake index 454633f8dd..f65c511ed8 100644 --- a/deps/cmake/ExternalProjectOpenSSL.cmake +++ b/deps/cmake/ExternalProjectOpenSSL.cmake @@ -7,7 +7,7 @@ message(STATUS "Building OpenSSL library.") # WARNING: OPENSSL DOES NOT SUPPORT PARALLEL BUILDS. make -j1 MUST BE USED!!!!! -# Note, the following list was generated from running ls in the openssl directory +# Note, the following list was generated from running ls in the openssl directory # set(_openssl_installed_headers pem2.h pem.h ssl3.h ossl_typ.h dtls1.h err.h bn.h blowfish.h cms.h engine.h conf_api.h x509.h asn1_mac.h ui.h kssl.h sha.h symhacks.h asn1.h opensslconf.h bio.h rc2.h dh.h ui_compat.h x509v3.h ssl23.h conf.h md5.h x509_vfy.h txt_db.h safestack.h ecdsa.h objects.h pkcs12.h crypto.h opensslv.h pkcs7.h obj_mac.h buffer.h ssl.h srp.h camellia.h evp.h e_os2.h md4.h hmac.h aes.h comp.h cast.h rc4.h stack.h des.h ocsp.h ec.h ecdh.h rand.h ts.h pqueue.h dso.h seed.h modes.h ssl2.h rsa.h krb5_asn.h des_old.h ripemd.h whrlpool.h tls1.h mdc2.h dsa.h srtp.h asn1t.h cmac.h ebcdic.h idea.h lhash.h) @@ -16,7 +16,7 @@ list(TRANSFORM _openssl_installed_headers PREPEND "${CMAKE_SOURCE_DIR}/deps/loca if(APPLE) - + set(__SDKCMD "SDKROOT=${CMAKE_OSX_SYSROOT}") if(${CMAKE_C_COMPILER_TARGET}) set(__ARCH_FLAG "--target=${CMAKE_C_COMPILER_TARGET}") @@ -27,21 +27,21 @@ if(APPLE) # the ./Configure script ExternalProject_Add(ex_openssl PREFIX ${CMAKE_SOURCE_DIR}/deps/build/libssl - URL ${CMAKE_SOURCE_DIR}/deps/src/openssl-1.0.2t + URL ${CMAKE_SOURCE_DIR}/deps/src/openssl-1.0.2t INSTALL_DIR ${CMAKE_SOURCE_DIR}/deps/local BUILD_IN_SOURCE 1 CONFIGURE_COMMAND bash -c "env ${__SDKCMD} CC=\"${CMAKE_C_COMPILER}\" ./Configure darwin64-x86_64-cc no-rc5 --prefix= -fPIC -Os -g ${CMAKE_C_FLAGS} -Wno-everything -w" BUILD_COMMAND bash -c "SDKROOT=${CMAKE_OSX_SYSROOT} make -j1" INSTALL_COMMAND bash -c "SDKROOT=${CMAKE_OSX_SYSROOT} make -j1 install && cp ./libcrypto.a /ssl && cp ./libssl.a /ssl" - BUILD_BYPRODUCTS - ${CMAKE_SOURCE_DIR}/deps/local/lib/libssl.a - ${CMAKE_SOURCE_DIR}/deps/local/lib/libcrypto.a + BUILD_BYPRODUCTS + ${CMAKE_SOURCE_DIR}/deps/local/lib/libssl.a + ${CMAKE_SOURCE_DIR}/deps/local/lib/libcrypto.a ${_openssl_installed_headers} ) elseif(WIN32) ExternalProject_Add(ex_openssl PREFIX ${CMAKE_SOURCE_DIR}/deps/build/libssl - URL ${CMAKE_SOURCE_DIR}/deps/src/openssl-1.0.2t + URL ${CMAKE_SOURCE_DIR}/deps/src/openssl-1.0.2t INSTALL_DIR ${CMAKE_SOURCE_DIR}/deps/local BUILD_IN_SOURCE 1 CONFIGURE_COMMAND ./Configure mingw64 no-idea no-mdc2 no-rc5 --prefix= @@ -57,9 +57,9 @@ ExternalProject_Add(ex_openssl CONFIGURE_COMMAND env CC=${CMAKE_C_COMPILER} ./config no-rc5 --prefix= -fPIC -Os -g -Wno-everything BUILD_COMMAND make -j1 INSTALL_COMMAND make -j1 install_sw - BUILD_BYPRODUCTS - ${CMAKE_SOURCE_DIR}/deps/local/lib/libssl.a - ${CMAKE_SOURCE_DIR}/deps/local/lib/libcrypto.a + BUILD_BYPRODUCTS + ${CMAKE_SOURCE_DIR}/deps/local/lib/libssl.a + ${CMAKE_SOURCE_DIR}/deps/local/lib/libcrypto.a ${_openssl_installed_headers} ) endif() @@ -78,7 +78,7 @@ endif() target_compile_definitions(openssl INTERFACE HAS_OPENSSL) -add_dependencies(openssl libssla ex_openssl) +add_dependencies(openssl libssla libcryptoa) add_dependencies(libssla ex_openssl) add_dependencies(libcryptoa ex_openssl) set(HAS_OPENSSL TRUE CACHE BOOL "") From 035f5b6b2fb440a1b7f0dc78e0c2a1b7481cf9db Mon Sep 17 00:00:00 2001 From: Guihao Liang Date: Wed, 29 Apr 2020 11:27:26 -0700 Subject: [PATCH 2/3] address pr concerns --- cmake/MakeLibrary.cmake | 77 ++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/cmake/MakeLibrary.cmake b/cmake/MakeLibrary.cmake index 90232bd1fd..2c4a6626d1 100644 --- a/cmake/MakeLibrary.cmake +++ b/cmake/MakeLibrary.cmake @@ -1,8 +1,11 @@ # This is an internal function and should not be used Usage: # make_target_impl(target compile_flags sources requirements is_library SHARED) # -# Example: make_target_impl(fileio "-fPIC" "asyncurl.cpp;sysutils.cpp" -# "logger;dl;pthread;z" TRUE FALSE) +# cmake-format: off +# Example: make_target_impl(fileio "-fPIC" +# "asyncurl.cpp;sysutils.cpp" +# "logger;dl;pthread;z" +# TRUE FALSE) # # This generates a target library/binary with the given name. The optional # compile_flags are appended to the target compile flags. "-fPIC" is ALWAYS @@ -13,6 +16,8 @@ # if DYNAMIC is true, a dynamic library is built. # # Boost, pthread is always added as a default dependency. when possible. +# cmake-format: on + macro( make_target_impl NAME @@ -69,43 +74,67 @@ macro( # Ensure dependencies are tracked in order to make sure compilation order # matters. - if (REQUIREMENTS) - add_dependencies(${NAME} ${REQUIREMENTS}) + if(REQUIREMENTS) + add_dependencies(${NAME} ${REQUIREMENTS}) endif() # make sure dependencies are always built first - if (TC_EXTERNAL_DEPENDENCIES) + if(TC_EXTERNAL_DEPENDENCIES) add_dependencies(${NAME} ${TC_EXTERNAL_DEPENDENCIES}) endif() - if (external_dependencies) + if(external_dependencies) add_dependencies(${NAME} external_dependencies) endif() endmacro() -# This is an external function Usage: make_library(NAME target SOURCES a.cpp -# b.cpp REQUIRES libx liby MAC_REQUIRES libz libzz LINUX_REQUIRES libk libj -# [SHARED] [OUTPUT_NAME xxxx] [SHARED_ALL_DEFINED] [OBJECT] ) Example: +# cmake-format: off +# This is an external function +# Usage: +# make_library(NAME target +# SOURCES a.cpp b.cpp +# REQUIRES libx liby +# MAC_REQUIRES libz libzz +# LINUX_REQUIRES libk libj +# [SHARED] [OUTPUT_NAME xxxx] [SHARED_ALL_DEFINED] +# [OBJECT] +# ) +# Example: # -# make_library(NAME fileio SOURCES asyncurl.cpp sysutils.cpp wsconn.cpp -# s3_api.cpp hdfs.cpp REQUIRES logger dl pthread z curl xml2 openssl -# MAC_REQUIRES iconv ) This generates a library with the provided target name. +# make_library(NAME fileio +# SOURCES +# asyncurl.cpp +# sysutils.cpp +# wsconn.cpp +# s3_api.cpp +# hdfs.cpp +# REQUIRES +# logger dl pthread z curl xml2 openssl +# MAC_REQUIRES +# iconv +# ) +# This generates a library with the provided target name. # -# NAME and SOURCES must be specified. REQUIRES lists all dependent libraries. -# These can be: - other libraries built by the the turicreate build system - -# builtin libraries - system libraries MAC_REQUIRES lists all dependent -# libraries which are included only on Mac. LINUX_REQUIRES lists all dependent -# libraries which are included only on Linux. SHARED will build a shared library -# instead of a static library EXTERNAL_VISIBILITY will make the symbols be -# publicly visible. Default is hidden SHARED_ALL_DEFINED will require shared -# libraries to have all symbols defined OBJECT will build an object library -# instead of a static library +# NAME and SOURCES must be specified. +# REQUIRES lists all dependent libraries. These can be: +# - other libraries built by the the turicreate build system +# - builtin libraries +# - system libraries +# MAC_REQUIRES lists all dependent libraries which are included only on Mac. +# LINUX_REQUIRES lists all dependent libraries which are included only on Linux. +# SHARED will build a shared library instead of a static library +# EXTERNAL_VISIBILITY will make the symbols be publicly visible. Default is hidden +# SHARED_ALL_DEFINED will require shared libraries to have all symbols defined +# OBJECT will build an object library instead of a static library # -# All other targets which depends on this library (using the "requires" -# function) will automatically include all recursive dependencies. +# All other targets which depends on this library (using the "requires" function) +# will automatically include all recursive dependencies. # -# Boost, pthread is always added as a default dependency. when possible. +# Boost, pthread is always added as a default dependency. +# when possible. +# cmake-format: on + macro(make_library NAME) set(options SHARED EXTERNAL_VISIBILITY SHARED_ALL_DEFINED DEAD_STRIP OBJECT) set(one_value_args COMPILE_FLAGS OUTPUT_NAME EXPORT_LINUX_MAP_FILE From 44f572ac0bad15b106e37bd176b9e8dc5298d031 Mon Sep 17 00:00:00 2001 From: Guihao Liang Date: Wed, 29 Apr 2020 11:31:11 -0700 Subject: [PATCH 3/3] minor change --- cmake/MakeLibrary.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/MakeLibrary.cmake b/cmake/MakeLibrary.cmake index 2c4a6626d1..9b17821569 100644 --- a/cmake/MakeLibrary.cmake +++ b/cmake/MakeLibrary.cmake @@ -2,10 +2,11 @@ # make_target_impl(target compile_flags sources requirements is_library SHARED) # # cmake-format: off -# Example: make_target_impl(fileio "-fPIC" -# "asyncurl.cpp;sysutils.cpp" -# "logger;dl;pthread;z" -# TRUE FALSE) +# Example: +# make_target_impl(fileio "-fPIC" +# "asyncurl.cpp;sysutils.cpp" +# "logger;dl;pthread;z" +# TRUE FALSE) # # This generates a target library/binary with the given name. The optional # compile_flags are appended to the target compile flags. "-fPIC" is ALWAYS