Skip to content

Commit

Permalink
Added dependencies to source rpm
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrinn committed Sep 13, 2023
1 parent 86ad76e commit 86d602d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ IF(NOT USE_SYSTEM_INSTALLED_LIB)
ENDIF()
ELSE()
# Adding mariadb subdirs of standard include locations
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} "/usr/local/include/mariadb")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} "/usr/include/mariadb")
INCLUDE_DIRECTORIES("/usr/local/include/mariadb")
MESSAGE(STATUS "Linking against libmariadb installed on the system")
ENDIF()

Expand Down Expand Up @@ -379,7 +379,15 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/mariadb-odbc-driver.def.in

IF(MARIADB_LINK_DYNAMIC)# OR USE_SYSTEM_INSTALLED_LIB)
IF(USE_SYSTEM_INSTALLED_LIB)
SET(MARIADB_CLIENT_TARGET_NAME mariadb)
FIND_PACKAGE(mariadb-connector-c)
IF(MARIADB-CONNECTOR-C_FOUND)
MESSAGE(STATUS "Found mariadb-connector-c package")
INCLUDE_DIRECTORIES(${MARIADB-CONNECTO-C_INCLUDE_DIR})
SET(MARIADB_CLIENT_TARGET_NAME ${MARIADB-CONNECTO-C_LIBRARIES})
ELSE()
INCLUDE_DIRECTORIES(/usr/include/mariadb /usr/include/mysql)
SET(MARIADB_CLIENT_TARGET_NAME mariadb)
ENDIF()
ELSE()
SET(MARIADB_CLIENT_TARGET_NAME libmariadb)
ENDIF()
Expand Down Expand Up @@ -503,6 +511,7 @@ ELSE()
IF(CMAKE_VERSION VERSION_GREATER "3.9.99")

SET(CPACK_SOURCE_GENERATOR "RPM")
SET(CPACK_RPM_BUILDREQUIRES "cmake;unixODBC-devel;mariadb-connector-c")
SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-DRPM=${RPM}")

MACRO(ADDIF var)
Expand All @@ -513,8 +522,15 @@ ELSE()

ADDIF(CMAKE_BUILD_TYPE)
ADDIF(BUILD_CONFIG)
ADDIF(MARIADB_LINK_DYNAMIC)
#ADDIF(CMAKE_C_FLAGS_RELWITHDEBINFO)
#ADDIF(DCMAKE_CXX_FLAGS_RELWITHDEBINFO)
#ADDIF(WITH_SSL)

INCLUDE(build_depends)
MESSAGE(STATUS "Build dependencies of the source RPM are: ${CPACK_RPM_BUILDREQUIRES}")
MESSAGE(STATUS "Cmake params for build from source RPM: ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS}")

ENDIF()
ELSE()
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/packaging/linux/postinstall")
Expand Down
47 changes: 47 additions & 0 deletions cmake/build_depends.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
IF(RPM)
MACRO(FIND_DEP V)
SET(out ${V}_DEP)
IF (NOT DEFINED ${out})
IF(EXISTS ${${V}} AND NOT IS_DIRECTORY ${${V}})
EXECUTE_PROCESS(COMMAND ${ARGN} RESULT_VARIABLE res OUTPUT_VARIABLE O OUTPUT_STRIP_TRAILING_WHITESPACE)
ELSE()
SET(res 1)
ENDIF()
IF (res)
SET(O)
ELSE()
MESSAGE(STATUS "Need ${O} for ${${V}}")
ENDIF()
SET(${out} ${O} CACHE INTERNAL "Package that contains ${${V}}" FORCE)
ENDIF()
ENDMACRO()

# FindBoost.cmake doesn't leave any trace, do it here
IF (Boost_INCLUDE_DIR)
FIND_FILE(Boost_config_hpp boost/config.hpp PATHS ${Boost_INCLUDE_DIR})
ENDIF()

GET_CMAKE_PROPERTY(ALL_VARS CACHE_VARIABLES)
FOREACH (V ${ALL_VARS})
GET_PROPERTY(H CACHE ${V} PROPERTY HELPSTRING)
IF (H MATCHES "^Have library [^/]" AND ${V})
STRING(REGEX REPLACE "^Have library " "" L ${H})
SET(V ${L}_LIBRARY)
FIND_LIBRARY(${V} ${L})
ENDIF()
GET_PROPERTY(T CACHE ${V} PROPERTY TYPE)
IF ((T STREQUAL FILEPATH OR V MATCHES "^CMAKE_COMMAND$") AND ${V} MATCHES "^/")
IF (RPM)
FIND_DEP(${V} rpm -q --qf "%{NAME}" -f ${${V}})
ELSE() # must be DEB
MESSAGE(FATAL_ERROR "Not implemented")
ENDIF ()
SET(BUILD_DEPS ${BUILD_DEPS} ${${V}_DEP})
ENDIF()
ENDFOREACH()
IF (BUILD_DEPS)
SET(BUILD_DEPS "${CPACK_RPM_BUILDREQUIRES}" "${BUILD_DEPS}")
LIST(REMOVE_DUPLICATES BUILD_DEPS)
STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}")
ENDIF()
ENDIF(RPM)

0 comments on commit 86d602d

Please sign in to comment.