From fb395fb24d6c4072563fe8f991efc3c5e1eefbb2 Mon Sep 17 00:00:00 2001 From: Massimo Mezzadri Date: Wed, 7 Nov 2012 10:27:19 +0100 Subject: [PATCH] aded CMakeLists.txt files to compile with cmake --- CMakeLists.txt | 52 +++++++++++++++ config/CMakeLists.txt | 24 +++++++ doc/CMakeLists.txt | 47 ++++++++++++++ src/CMakeLists.txt | 144 ++++++++++++++++++++++++++++++++++++++++++ src/FindClassAd.cmake | 112 ++++++++++++++++++++++++++++++++ src/acconfig.h | 0 6 files changed, 379 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 config/CMakeLists.txt create mode 100644 doc/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/FindClassAd.cmake create mode 100644 src/acconfig.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..eb9e0045 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +# **************** +# * BLAHP daemon * +# **************** +# +# $Id: $ +# +# File: CMakeLists.txt +# +# Author(s): Francesco Prelz ($Author: $) +# e-mail: "Francesco.Prelz@mi.infn.it" +# +# Revision history: +# +# 5-Nov-2012 Created + +cmake_minimum_required(VERSION 2.6) + +project(BLAH) + +# CPack info + +if (UNIX AND NOT APPLE) +set(CPACK_GENERATOR "STGZ;DEB;RPM") +execute_process(COMMAND uname -i + OUTPUT_VARIABLE local_arch OUTPUT_STRIP_TRAILING_WHITESPACE) +set(CPACK_SYSTEM_NAME ${local_arch}) +endif (UNIX AND NOT APPLE) + +set(CPACK_PACKAGE_VENDOR "EMI") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Batch Local ASCII Helper Protocol suite") +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "19") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_VERSION + "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +set(CPACK_PACKAGE_CONTACT "blah@mi.infn.it") +set(CPACK_RPM_PACKAGE_LICENSE "Apache Software License") +set(CPACK_RPM_PACKAGE_RELEASE "0") +set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet") + +set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/project/glite-ce-blahp.post) +set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/project/glite-ce-blahp.preun) + +add_subdirectory(src build) +add_subdirectory(config) +add_subdirectory(doc) + +install(FILES LICENSE + DESTINATION share/doc/${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}) diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt new file mode 100644 index 00000000..54882f81 --- /dev/null +++ b/config/CMakeLists.txt @@ -0,0 +1,24 @@ +# **************** +# * BLAHP daemon * +# **************** +# +# $Id: $ +# +# File: CMakeLists.txt +# +# Author(s): Francesco Prelz ($Author: $) +# e-mail: "Francesco.Prelz@mi.infn.it" +# +# Revision history: +# +# 5-Nov-2012 Created + +cmake_minimum_required(VERSION 2.6) + +install(FILES + blah.config.template + blparser.conf.template + glite-ce-blah-parser + glite-ce-check-blparser + DESTINATION etc) + diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..d091e419 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,47 @@ +# **************** +# * BLAHP daemon * +# **************** +# +# $Id: $ +# +# File: CMakeLists.txt +# +# Author(s): Francesco Prelz ($Author: $) +# e-mail: "Francesco.Prelz@mi.infn.it" +# +# Revision history: +# +# 5-Nov-2012 Created + +cmake_minimum_required(VERSION 2.6) + +find_program(XSLTPROC_EXECUTABLE xsltproc) + +find_file(XSLTPROC_MANPAGE_STYLESHEET + NAMES docbook.xsl + PATHS /usr/share/sgml/docbook/xsl-stylesheets/manpages) + +set(MAN1PAGES_TO_CREATE + blah_job_registry_add.1 + blah_job_registry_dump.1 + blah_job_registry_lkup.1 + blah_job_registry_scan_by_subject.1 + blah_check_config.1 + blahpd.1 +) + +foreach (manpage ${MAN1PAGES_TO_CREATE}) + string(REGEX REPLACE ".[1-9]$" ".xml" manpage_src ${manpage}) + add_custom_command(OUTPUT ${manpage} + COMMAND ${XSLTPROC_EXECUTABLE} + ${XSLTPROC_MANPAGE_STYLESHEET} + ${manpage_src} + DEPENDS ${manpage_src}) + set_source_files_properties(${manpage} PROPERTIES GENERATED TRUE) +endforeach() + +add_custom_target(all_manpages ALL + DEPENDS ${MAN1PAGES_TO_CREATE} ) + +install(FILES ${MAN1PAGES_TO_CREATE} DESTINATION man/man1) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..b8d82f1e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,144 @@ +# **************** +# * BLAHP daemon * +# **************** +# +# $Id: $ +# +# File: CMakeLists.txt +# +# Author(s): Francesco Prelz ($Author: $) +# e-mail: "Francesco.Prelz@mi.infn.it" +# +# Revision history: +# +# 26-Oct-2012 Created + +cmake_minimum_required(VERSION 2.6) + +include(FindClassAd.cmake) +include_directories(${ClassAd_INCLUDE_DIR}) +include(FindPkgConfig) + +pkg_check_modules(GLOBUS_COMMON globus-common) +include_directories(${GLOBUS_COMMON_INCLUDE_DIRS}) + +pkg_check_modules(GLOBUS_IO globus-io) +pkg_check_modules(GLOBUS_GSSAPI_GSI globus-gssapi-gsi) +pkg_check_modules(GLOBUS_GSS_ASSIST globus-gss-assist) +pkg_check_modules(GLOBUS_GSI_CREDENTIAL globus-gsi-credential) +pkg_check_modules(GLOBUS_GSI_PROXY_CORE globus-gsi-proxy-core) + +include_directories(.) + +set (main_common_sources + console.c job_status.c resbuffer.c server.c commands.c + classad_binary_op_unwind.C classad_c_helper.C proxy_hashcontainer.c + config.c job_registry.c blah_utils.c env_helper.c mapped_exec.c md5.c + cmdbuffer.c) + +set (bupdater_common_sources + Bfunctions.c job_registry.c md5.c config.c blah_utils.c + job_registry_updater.c) + +# programs for 'sbin' +add_executable(blahpd_daemon main_daemon.c ${main_common_sources}) +set_target_properties(blahpd_daemon PROPERTIES COMPILE_FLAGS ${ClassAd_CXX_FLAGS}) +target_link_libraries(blahpd_daemon -lpthread ${ClassAd_LIBRARY}) +add_executable(blah_job_registry_add + blah_job_registry_add.c job_registry.c + job_registry_updater.c md5.c config.c) +add_executable(blah_job_registry_lkup + blah_job_registry_lkup.c job_registry.c md5.c config.c) +add_executable(blah_job_registry_scan_by_subject + blah_job_registry_scan_by_subject.c classad_c_helper.C + classad_binary_op_unwind.C job_registry.c md5.c config.c) +set_target_properties(blah_job_registry_scan_by_subject PROPERTIES COMPILE_FLAGS ${ClassAd_CXX_FLAGS}) +target_link_libraries(blah_job_registry_scan_by_subject ${ClassAd_LIBRARY}) +add_executable(blah_check_config + blah_check_config.c Bfunctions.c config.c blah_utils.c) +add_executable(blah_job_registry_dump + blah_job_registry_dump.c job_registry.c md5.c config.c) +add_executable(blah_job_registry_purge + blah_job_registry_purge.c job_registry.c md5.c) + +# programs for 'bin' +add_executable(blahpd main.c ${main_common_sources}) +set_target_properties(blahpd PROPERTIES COMPILE_FLAGS ${ClassAd_CXX_FLAGS}) +target_link_libraries(blahpd -lpthread ${ClassAd_LIBRARY}) + +# programs for 'libexec' +add_executable(BLClient BLClient.c blah_utils.c BLfunctions.c) +add_executable(BLParserLSF BLParserLSF.c blah_utils.c BLfunctions.c) +target_link_libraries(BLParserLSF -lpthread) +add_executable(BLParserPBS BLParserPBS.c blah_utils.c BLfunctions.c) +target_link_libraries(BLParserPBS -lpthread) +add_executable(BUpdaterCondor BUpdaterCondor.c ${bupdater_common_sources}) +target_link_libraries(BUpdaterCondor -lpthread) +add_executable(BNotifier + BNotifier.c Bfunctions.c job_registry.c md5.c config.c blah_utils.c) +target_link_libraries(BNotifier -lpthread) +add_executable(BUpdaterLSF BUpdaterLSF.c ${bupdater_common_sources}) +target_link_libraries(BUpdaterLSF -lpthread -lm) +add_executable(BUpdaterPBS BUpdaterPBS.c ${bupdater_common_sources}) +target_link_libraries(BUpdaterPBS -lpthread -lm) +add_executable(BUpdaterSGE + BUpdaterSGE.c Bfunctions.c job_registry.c md5.c config.c + blah_utils.c) +add_executable(blparser_master blparser_master.c config.c blah_utils.c) + +if (${GLOBUS_COMMON_FOUND} AND ${GLOBUS_IO_FOUND}) +add_executable(BPRclient BPRclient.c BPRcomm.c tokens.c) +target_link_libraries(BPRclient + ${GLOBUS_GSI_PROXY_CORE_LDFLAGS} + ${GLOBUS_GSI_CREDENTIALS_LDFLAGS} + ${GLOBUS_GSS_ASSIST_LDFLAGS}) +add_executable(BPRserver BPRserver.c BPRcomm.c tokens.c) +target_link_libraries(BPRserver + ${GLOBUS_GSI_PROXY_CORE_LDFLAGS} + ${GLOBUS_GSI_CREDENTIALS_LDFLAGS} + ${GLOBUS_GSS_ASSIST_LDFLAGS}) +set_target_properties(BPRserver PROPERTIES COMPILE_FLAGS "-static") +endif (${GLOBUS_COMMON_FOUND} AND ${GLOBUS_IO_FOUND}) + +# test programs +add_executable(test_job_registry_create test_job_registry_create.c job_registry.c md5.c) +add_executable(test_job_registry_purge test_job_registry_purge.c job_registry.c md5.c) +add_executable(test_job_registry_update test_job_registry_update.c job_registry.c md5.c) +add_executable(test_job_registry_access test_job_registry_access.c job_registry.c md5.c) +add_executable(test_job_registry_update_from_network + test_job_registry_update_from_network.c job_registry.c + job_registry_updater.c md5.c config.c) +add_executable(test_cmdbuffer cmdbuffer.c) +set_target_properties(test_cmdbuffer PROPERTIES COMPILE_FLAGS "-DCMDBUF_DEBUG") + +# CPack info + +install(TARGETS blahpd RUNTIME DESTINATION bin) +install(TARGETS + blahpd_daemon blah_job_registry_add blah_job_registry_lkup + blah_job_registry_scan_by_subject blah_check_config + blah_job_registry_dump blah_job_registry_purge + RUNTIME DESTINATION sbin) +install(TARGETS + BLClient BLParserLSF BLParserPBS BUpdaterCondor BNotifier + BUpdaterLSF BUpdaterPBS BUpdaterSGE + blparser_master + RUNTIME DESTINATION libexec) +install(FILES + scripts/blah_load_config.sh scripts/blah_common_submit_functions.sh + scripts/pbs_cancel.sh scripts/pbs_status.sh scripts/pbs_submit.sh + scripts/pbs_hold.sh scripts/pbs_resume.sh scripts/lsf_cancel.sh + scripts/lsf_status.sh scripts/lsf_submit.sh scripts/lsf_hold.sh + scripts/lsf_resume.sh scripts/condor_cancel.sh scripts/condor_status.sh + scripts/condor_submit.sh scripts/condor_hold.sh scripts/condor_resume.sh + scripts/sge_cancel.sh scripts/sge_helper scripts/sge_resume.sh + scripts/sge_submit.sh scripts/sge_filestaging scripts/sge_hold.sh + scripts/sge_status.sh scripts/runcmd.pl.template + scripts/sge_local_submit_attributes.sh + DESTINATION libexec) + +if (${GLOBUS_COMMON_FOUND} AND ${GLOBUS_IO_FOUND}) +install(TARGETS BPRclient BPRserver RUNTIME DESTINATION libexec) +endif (${GLOBUS_COMMON_FOUND} AND ${GLOBUS_IO_FOUND}) + +include(CPack) diff --git a/src/FindClassAd.cmake b/src/FindClassAd.cmake new file mode 100644 index 00000000..a5a3e4b5 --- /dev/null +++ b/src/FindClassAd.cmake @@ -0,0 +1,112 @@ +# - Finds Condor Classified Ad (Classad) binary distribution. +# The following variables are set: +# ClassAd_CXX_FLAGS - flags to add to the CXX compiler for Classad support +# CLASSAD_FOUND - true if the Classad distribution is detected +# +# Supported compilers can be found at http://openmp.org/wp/openmp-compilers/ + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) +include(FindPackageHandleStandardArgs) + +set(ClassAd_INCLUDE_PATH_DESCRIPTION "top-level directory containing the Condor ClassAd include directories. E.g /opt/classad/include") +set(ClassAd_INCLUDE_DIR_MESSAGE "Set the ClassAd_INCLUDE_DIR cmake cache entry to the ${ClassAd_INCLUDE_PATH_DESCRIPTION}") +set(ClassAd_LIBRARY_PATH_DESCRIPTION "top-level directory containing the Condor ClassAd libraries.") +set(ClassAd_LIBRARY_DIR_MESSAGE "Set the ClassAd_LIBRARY_DIR cmake cache entry to the ${ClassAd_LIBRARY_PATH_DESCRIPTION}") + +find_path(ClassAd_INCLUDE_DIR + NAMES classad_distribution.h + PATHS + # Look in other places. + ${ClassAd_ROOT_DIRECTORIES} + PATH_SUFFIXES + classad + include + # Help the user find it if we cannot. + DOC "The ${ClassAd_INCLUDE_DIR_MESSAGE}" +) + +message(STATUS "ClassAd_INCLUDE_DIR == " ${ClassAd_INCLUDE_DIR}) + +# The ClassAd library (should have namespaces enabled). +set (ClassAd_LIBRARY_TO_FIND classad_ns) + +# Setting some more prefixes for the library +set (ClassAd_LIB_PREFIX "") +if ( WIN32 ) + set (ClassAd_LIB_PREFIX ${ClassAd_LIB_PREFIX} "lib") + set ( ClassAd_LIBRARY_TO_FIND ${ClassAd_LIB_PREFIX}${ClassAd_LIBRARY_TO_FIND}) +endif() + +find_library( ClassAd_LIBRARY + NAMES ${ClassAd_LIBRARY_TO_FIND} + PATHS + ${ClassAd_LIBRARY_DIR} + PATH_SUFFIXES + lib +) + +get_filename_component(ClassAd_LIBRARY_DIR ${ClassAd_LIBRARY} PATH) +message(STATUS "ClassAd_LIBRARY == " ${ClassAd_LIBRARY}) + +# sample Classad source code to test +set(ClassAd_CXX_TEST_SOURCE +" +#include +classad::ClassAd ad; +classad::ClassAdParser parser; + +int +main(int argc, char *argv[]) +{ +} +") + +set(ClassAd_CXX_FLAG_CANDIDATES + "-DWANT_NAMESPACES" + "-DWANT_NAMESPACES -DWANT_CLASSAD_NAMESPACE" +) + +# check cxx compiler +foreach(FLAG ${ClassAd_CXX_FLAG_CANDIDATES}) + set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + set(SAFE_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") + set(CMAKE_REQUIRED_FLAGS "${FLAG}") + set(CMAKE_REQUIRED_LIBRARIES "${ClassAd_LIBRARY}") + set(CMAKE_REQUIRED_INCLUDES "${ClassAd_INCLUDE_DIR}") + unset(ClassAd_FLAG_DETECTED CACHE) + message(STATUS "Try Classad CXX flag = [${FLAG}] (library = [${ClassAd_LIBRARY}])") + check_cxx_source_compiles("${ClassAd_CXX_TEST_SOURCE}" ClassAd_FLAG_DETECTED) + set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") + set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") + set(CMAKE_REQUIRED_INCLUDES "${SAFE_CMAKE_REQUIRED_INCLUDES}") + if(ClassAd_FLAG_DETECTED) + set(ClassAd_CXX_FLAGS_INTERNAL "${FLAG}") + break() + endif(ClassAd_FLAG_DETECTED) +endforeach(FLAG ${ClassAd_CXX_FLAG_CANDIDATES}) + +set(ClassAd_CXX_FLAGS "${ClassAd_CXX_FLAGS_INTERNAL}" + CACHE STRING "C++ compiler flags for use of the Condor Classad library") +message(STATUS "ClassAd_CXX_FLAGS == " ${ClassAd_CXX_FLAGS}) +# handle the standard arguments for find_package +find_package_handle_standard_args(ClassAd DEFAULT_MSG + ClassAd_LIBRARY ClassAd_INCLUDE_DIR) + +mark_as_advanced( + ClassAd_CXX_FLAGS + ClassAd_LIBRARY +) diff --git a/src/acconfig.h b/src/acconfig.h new file mode 100644 index 00000000..e69de29b