Skip to content

Commit

Permalink
add libmng
Browse files Browse the repository at this point in the history
  • Loading branch information
madmongo1 committed Oct 1, 2016
1 parent 3aec28a commit 0244f0e
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/require_devil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function (sanity_require_devil given_version)
sanity_require(LIBRARY jpeg VERSION any)
sanity_require(LIBRARY tiff VERSION any)
sanity_require(LIBRARY lcms VERSION any)
sanity_require(LIBRARY libmng VERSION any)

set (repo_name libdevil)
set (package_name "${library}-${version}")
Expand Down
160 changes: 160 additions & 0 deletions cmake/require_libmng.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
include (${CMAKE_CURRENT_LIST_DIR}/sanity_deduce_version.cmake)


function (sanity_require_libmng given_version)

set (library libmng)
set (versions 1.0.10)
set (hashes 1.0.10)
sanity_back(versions latest_version)

sanity_deduce_version(${given_version} versions ${library} version version_index)
if (NOT version)
message (FATAL_ERROR "unable to deduce version")
endif ()

list (GET hashes ${version_index} required_commit)

set (complete_flag "sanity.require_${library}.complete")
if (${${complete_flag}})
return ()
endif ()

sanity_require(LIBRARY jpeg VERSION any)

set (repo_name libmng)
set (package_name "${library}-${version}")
set (flag_base ${sanity.source.cache.flags}/)

set (master_repo_base "${sanity.source.cache}/git")
set (master_repo "${master_repo_base}/${repo_name}.git")

if (NOT EXISTS "${master_repo_base}")
file (MAKE_DIRECTORY "${master_repo_base}")
endif ()
sanity_make_flag(master_clone_flag "source.cache" "${package_name}" "master_clone")
if (NOT EXISTS "${master_repo}")
FILE (REMOVE "${master_clone_flag}")
endif ()
if (NOT EXISTS "${master_clone_flag}")
if (EXISTS "${master_repo}")
FILE (REMOVE_RECURSE "${master_repo}")
endif ()
execute_process(COMMAND "git" "clone" "https://github.com/madmongo1/${repo_name}.git"
"--mirror"
"--progress"
WORKING_DIRECTORY ${master_repo_base}
RESULT_VARIABLE res)
if (res)
message (FATAL_ERROR "${res}")
endif ()
sanity_touch_flag(master_clone_flag)
endif ()

sanity_make_current_system_flag(create_repo PACKAGE "${package_name}" FUNCTION "create_repo")
sanity_make_current_system_flag(checkout PACKAGE "${package_name}" FUNCTION "checkout")
sanity_current_system_path(SRC local_src)
set (src "${local_src}/${package_name}")

if (NOT EXISTS ${src})
FILE (REMOVE ${create_repo})
endif ()
if (NOT EXISTS ${create_repo})
FILE (REMOVE_RECURSE ${src})
execute_process(COMMAND "git" "clone" "--shared" "${master_repo}" "${package_name}"
WORKING_DIRECTORY "${local_src}"
RESULT_VARIABLE res)
if (res)
message (FATAL_ERROR "${res}")
endif ()
endif ()

execute_process(COMMAND "git" "rev-parse" "HEAD"
WORKING_DIRECTORY "${src}"
OUTPUT_VARIABLE out OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE res)
if (res)
message (FATAL_ERROR "${res}")
endif ()
if (NOT "${out}" STREQUAL "${required_commit}")
FILE (REMOVE ${checkout})
endif ()

if ("${create_repo}" IS_NEWER_THAN "${checkout}")
execute_process(COMMAND "git" "checkout" "${required_commit}"
WORKING_DIRECTORY "${src}" RESULT_VARIABLE res)
if (res)
message (FATAL_ERROR "${res}")
endif ()
sanity_touch_flag(checkout)
endif ()

sanity_make_current_system_flag(configure PACKAGE "${package_name}" FUNCTION "configure")
sanity_current_system_path(BUILD local_build)
sanity_current_system_path(LOCAL target_local)
set (build_dir "${local_build}/${package_name}")

if (NOT EXISTS "${build_dir}")
FILE(REMOVE "${configure}")
FILE(MAKE_DIRECTORY "${build_dir}")
endif ()


if ("${checkout}" IS_NEWER_THAN "${configure}")
execute_process(COMMAND "${CMAKE_COMMAND}"
"-DCMAKE_PREFIX_PATH=${target_local}"
"-DCMAKE_INSTALL_PREFIX:PATH=${target_local}"
"${src}"
WORKING_DIRECTORY "${build_dir}"
RESULT_VARIABLE res)
if (res)
message (FATAL_ERROR "${res}")
endif ()
sanity_touch_flag(configure)
endif ()

sanity_make_current_system_flag(clean PACKAGE "${package_name}" FUNCTION "clean")
sanity_make_current_system_flag(build PACKAGE "${package_name}" FUNCTION "build")
sanity_make_current_system_flag(install PACKAGE "${package_name}" FUNCTION "install")

if ("${configure}" IS_NEWER_THAN "${clean}")
execute_process(COMMAND make "-j${sanity.concurrency}" clean
WORKING_DIRECTORY ${build_dir})
sanity_touch_flag(clean)
endif ()

if ("${clean}" IS_NEWER_THAN "${build}")
execute_process(COMMAND make "-j${sanity.concurrency}"
WORKING_DIRECTORY ${build_dir})
sanity_touch_flag(build)
endif ()

if ("${build}" IS_NEWER_THAN "${install}")
execute_process(COMMAND make install
WORKING_DIRECTORY ${build_dir})
sanity_touch_flag(install)
endif ()


set(component_names LIBMNG_INCLUDE_DIRS LIBMNG_LIBRARIES LIBMNG_FOUND LIBMNG_VERSION_STRING)
set(LIBMNG_INCLUDE_DIRS "${target_local}/include")
set(LIBMNG_LIBRARIES "${target_local}/lib/libamqp-cpp.a")
set(LIBMNG_FOUND True)
set(LIBMNG_VERSION_STRING "${version}")

if (NOT TARGET sanity::libmng)
add_library(sanity::libmng INTERFACE IMPORTED GLOBAL)
target_link_libraries(sanity::libmng
INTERFACE ${LIBMNG_LIBRARIES})
set_property(TARGET sanity::libmng
APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBMNG_INCLUDE_DIRS})
endif ()

set (${complete_flag} TRUE)

sanity_propagate_vars(${component_names}
${complete_flag})


endfunction()
6 changes: 6 additions & 0 deletions cmake/sanity.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ function (sanity_require)
jpeg
lcms
ldns
libmng
openssl
protobuf
mysql
Expand Down Expand Up @@ -436,6 +437,10 @@ function (sanity_require)
sanity_require_lcms(${version})
endif ()

if (libname STREQUAL "libmng")
sanity_require_libmng(${version})
endif ()

if (libname STREQUAL "mysql")
sanity_require_mysql (${version})
endif ()
Expand Down Expand Up @@ -478,6 +483,7 @@ include ("${CMAKE_CURRENT_LIST_DIR}/require_icu.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/require_jpeg.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/require_lcms.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/require_ldns.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/require_libmng.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/require_mysql.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/require_mysqlcppcon.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/require_openssl.cmake")
Expand Down

0 comments on commit 0244f0e

Please sign in to comment.