Commit 87e80ffc authored by Joern jkuensem's avatar Joern jkuensem

SW-822: Merge branch LSMR-epic to master

parents 54467a70 d0e4b4d5
# - Try to find NPM.
# Variables used by this module:
# NPM_ROOT_DIR - NPM root directory
# Variables defined by this module:
# NPM_FOUND - system has NPM
# NPM_ROOT - hint to the path where npm is located
# NPM_EXECUTABLE - path to the npm executable
# Copyright (C) 2009
# ASTRON (Netherlands Institute for Radio Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This file is part of the LOFAR software suite.
# The LOFAR software suite is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The LOFAR software suite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
#
# $Id: FindALGLIB.cmake 21886 2012-09-04 11:57:26Z mol $
if(NOT NPM_FOUND)
find_program(NPM_EXECUTABLE NAMES npm HINTS ENV/npm ${NPM_ROOT}/npm)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args (NPM REQUIRED_VARS NPM_EXECUTABLE)
endif(NOT NPM_FOUND)
cmake_minimum_required(VERSION 2.8)
#setup cpack variables and configuration
set(CPACK_PACKAGE_NAME "lofar")
set(CPACK_PACKAGE_FILE_NAME "lofar")
set(CPACK_PACKAGE_VENDOR "Astron")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A lofar rpm package. <TODO: add summary>")
set(CPACK_RPM_PACKAGE_DESCRIPTION "A lofar rpm package. <TODO: add description>")
set(CPACK_RPM_PACKAGE_GROUP "radio astronomy")
set(CPACK_RPM_PACKAGE_LICENSE "GPL3")
# these lofar software version numbers are applied to each rpm package
set(CPACK_PACKAGE_VERSION_MAJOR "3")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_SET_DESTDIR ON)
set(CPACK_PACKAGE_RELOCATABLE FALSE)
set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE)
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP) #creates one package file per component group (one package file per lofar package)
set(CPACK_RPM_PACKAGE_AUTOREQ OFF) # AUTOREQ is a nice feaure, but it also detects 'packages' like casa, for which we do not have rpm's (yet). So currently disabled.
#if we install in "/opt/lofar" or any other path starting with default unix directories
# we do not want the install the /opt (or other default unix) dir, because that will conflict with rpm package "filesystem", which setsup the default linux filesystem
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "/opt;/home;/usr;/tmp")
# fire up cmake cpack module.
include(CPack)
......@@ -21,7 +21,7 @@
#
# $Id$
# Only process this file when we're ate the top-level source directory.
# Only process this file when we're at the top-level source directory.
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
# Configure header containing global configurations for LOFAR builds.
......@@ -41,7 +41,21 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
install(FILES
${CMAKE_BINARY_DIR}/lofarinit.sh
${CMAKE_BINARY_DIR}/lofarinit.csh
DESTINATION .)
DESTINATION .
COMPONENT "lofarbase")
# -- cpack
string(TOLOWER ${CMAKE_PROJECT_NAME} lower_project)
set(CPACK_lofarbase_PACKAGE_NAME "${lower_project}-lofarbase" CACHE INTERNAL "cpack component-package name for lofar-package lofarbase")
set(CPACK_RPM_lofarbase_FILE_NAME "RPM-DEFAULT" CACHE INTERNAL "")
# setup base directory structure
install(DIRECTORY
${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/sbin ${CMAKE_BINARY_DIR}/var ${CMAKE_BINARY_DIR}/etc ${CMAKE_BINARY_DIR}/share
DESTINATION .
COMPONENT "lofarbase"
FILES_MATCHING PATTERN "non_matching_pattern.foo" # trick to prevent installation of files in directories
)
# -- end cpack
# Configure the CTestCustom.cmake file, used by CTest/Dart, if it exists.
if(EXISTS ${CMAKE_SOURCE_DIR}/CTestCustom.cmake.in)
......
......@@ -49,9 +49,12 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# the directory <build-dir>/bin.
# --------------------------------------------------------------------------
macro(lofar_add_bin_program _name)
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
lofar_add_executable(${_name} ${ARGN})
install(TARGETS ${_name} DESTINATION bin)
set_target_properties(${_name} PROPERTIES
install(TARGETS ${_name}
DESTINATION bin
COMPONENT ${lower_package_name})
set_target_properties(${_name} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endmacro(lofar_add_bin_program)
......@@ -76,11 +79,14 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# Also create a symbolic link in <build-dir>/bin to each of these scripts.
# --------------------------------------------------------------------------
function(lofar_add_bin_script _name)
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
get_filename_component(_abs_name ${_name} ABSOLUTE)
get_filename_component(_base_name ${_name} NAME)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_abs_name} ${CMAKE_BINARY_DIR}/bin/${_base_name})
install(PROGRAMS ${_name} DESTINATION bin ${ARGN})
install(PROGRAMS ${_name}
DESTINATION bin
COMPONENT ${lower_package_name})
endfunction(lofar_add_bin_script)
# --------------------------------------------------------------------------
......@@ -127,6 +133,7 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# lofar_package().
# --------------------------------------------------------------------------
macro(lofar_add_library _name)
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
add_library(${_name} ${ARGN})
if(NOT "${ARGN}" MATCHES "^MODULE")
set_property(GLOBAL APPEND PROPERTY ${PACKAGE_NAME}_LIBRARIES ${_name})
......@@ -144,7 +151,9 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# set_target_properties(${_name} PROPERTIES
# VERSION ${${PACKAGE_NAME}_VERSION}
# OUTPUT_NAME lofar_${_name})
install(TARGETS ${_name} DESTINATION ${LOFAR_LIBDIR})
install(TARGETS ${_name}
DESTINATION ${LOFAR_LIBDIR}
COMPONENT ${lower_package_name})
set_target_properties(${_name} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LOFAR_LIBDIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LOFAR_LIBDIR})
......@@ -163,9 +172,12 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# the directory <build-dir>/sbin.
# --------------------------------------------------------------------------
macro(lofar_add_sbin_program _name)
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
lofar_add_executable(${_name} ${ARGN})
install(TARGETS ${_name} DESTINATION sbin)
set_target_properties(${_name} PROPERTIES
install(TARGETS ${_name}
DESTINATION sbin
COMPONENT ${lower_package_name})
set_target_properties(${_name} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/sbin)
endmacro(lofar_add_sbin_program)
......@@ -177,12 +189,15 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# Also create a symbolic link in <build-dir>/sbin to each of these scripts.
# --------------------------------------------------------------------------
macro(lofar_add_sbin_scripts)
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
foreach(_name ${ARGN})
get_filename_component(_abs_name ${_name} ABSOLUTE)
get_filename_component(_base_name ${_name} NAME)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_abs_name} ${CMAKE_BINARY_DIR}/sbin/${_base_name})
install(PROGRAMS ${_name} DESTINATION sbin)
install(PROGRAMS ${_name}
DESTINATION sbin
COMPONENT ${lower_package_name})
endforeach(_name ${ARGN})
endmacro(lofar_add_sbin_scripts)
......@@ -206,6 +221,7 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
string(REGEX REPLACE ";?DESTINATION.*" "" _src_names "${ARGN}")
string(REGEX MATCH "DESTINATION;.*" _destination "${ARGN}")
string(REGEX REPLACE "^DESTINATION;" "" _destination "${_destination}")
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
foreach(_src_name ${_src_names})
if(_destination MATCHES ".+")
get_filename_component(_src_filename ${_src_name} NAME)
......@@ -220,7 +236,9 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/etc/${_dest_path})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_abs_name} ${CMAKE_BINARY_DIR}/etc/${_dest_name})
install(FILES ${_src_name} DESTINATION etc/${_dest_path})
install(FILES ${_src_name}
DESTINATION etc/${_dest_path}
COMPONENT ${lower_package_name})
endforeach(_src_name ${_src_names})
endmacro(lofar_add_sysconf_files)
......@@ -232,16 +250,37 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# installed into the <prefix>/share directory. Also create a symbolic link
# in <build-dir>/share to each of these files. The file names may contain
# a relative(!) path.
#
# The mentioned files are installed in the same relative path as provided,
# that is:
# lofar_add_data_files(foo/bar)
# installs "share/foo/bar". To override this behaviour use:
# lofar_add_data_files(foo/bar DESTINATION .)
# installs "share/bar".
# --------------------------------------------------------------------------
macro(lofar_add_data_files)
foreach(_name ${ARGN})
get_filename_component(_path ${_name} PATH)
get_filename_component(_abs_name ${_name} ABSOLUTE)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/${_path})
string(REGEX REPLACE ";?DESTINATION.*" "" _src_names "${ARGN}")
string(REGEX MATCH "DESTINATION;.*" _destination "${ARGN}")
string(REGEX REPLACE "^DESTINATION;" "" _destination "${_destination}")
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
foreach(_src_name ${_src_names})
if(_destination MATCHES ".+")
get_filename_component(_src_filename ${_src_name} NAME)
set(_dest_name ${_destination}/${_src_filename})
else(_destination MATCHES ".+")
set(_dest_name ${_src_name})
endif(_destination MATCHES ".+")
get_filename_component(_abs_name ${_src_name} ABSOLUTE)
get_filename_component(_dest_path ${_dest_name} PATH)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/${_dest_path})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_abs_name} ${CMAKE_BINARY_DIR}/share/${_name})
install(FILES ${_name} DESTINATION share/${_path})
endforeach(_name ${ARGN})
${_abs_name} ${CMAKE_BINARY_DIR}/share/${_dest_name})
install(FILES ${_src_name}
DESTINATION share/${_dest_path}
COMPONENT ${lower_package_name})
endforeach(_src_name ${_src_names})
endmacro(lofar_add_data_files)
......
......@@ -86,12 +86,17 @@ if(NOT LOFAR_PACKAGE_INCLUDED)
# Initialize PACKAGE_NAME to the name of the top-level project
set(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
string(TOLOWER ${CMAKE_PROJECT_NAME} _project)
set(CPACK_RPM_LofarInit_PACKAGE_NAME "${_project}-LofarInit" CACHE INTERNAL "")
############################################################################
function(lofar_add_package _pkg)
if(NOT DEFINED BUILD_${_pkg} OR BUILD_${_pkg})
message(STATUS "Adding package ${_pkg} as dependency of ${PACKAGE_NAME}")
add_dependencies(${PACKAGE_NAME} ${_pkg})
set(PACKAGE_NAME ${_pkg})
if(NOT TARGET ${_pkg})
string(REGEX REPLACE ";?REQUIRED$" "" _srcdir "${ARGN}")
......@@ -172,6 +177,40 @@ if(NOT LOFAR_PACKAGE_INCLUDED)
message(STATUS " ${_pkg} dependencies: ${${_pkg}_DEPENDENCIES}")
endif(LOFAR_VERBOSE_CONFIGURE)
# -- cpack --
# create and set the component-package name
# for the component-package name we need the project and lofar-package name in lowecase
string(TOLOWER ${CMAKE_PROJECT_NAME} lower_project_name)
string(TOLOWER ${_pkg} lower_pkg_name)
string(TOLOWER ${_pkg} lower_parent_pkg)
set(CPACK_${lower_pkg_name}_PACKAGE_NAME "${lower_project_name}-${lower_pkg_name}" CACHE INTERNAL "cpack component-package name for lofar-package ${_pkg}")
set(CPACK_RPM_${lower_pkg_name}_FILE_NAME "RPM-DEFAULT" CACHE INTERNAL "")
# only set cpack dependencies between actual packages (the lofar project is not a package)
if(NOT _pkg MATCHES "${CMAKE_PROJECT_NAME}")
# jump through some hoops with cmake string/list manipulation
# we need to set CPACK_RPM_${lower_parent_pkg}_PACKAGE_REQUIRES with a comma seperated string of depency component-packages
# but make treats lists as semi-colon seperated string, so we need to do some conversions, and replacements.
if(DEFINED CPACK_RPM_${lower_parent_pkg}_PACKAGE_REQUIRES)
string(REPLACE "," ";" requirements_list ${CPACK_RPM_${lower_parent_pkg}_PACKAGE_REQUIRES})
else()
set(requirements_list "")
endif()
list(APPEND requirements_list "${lower_project_name}-lofarbase") # each and every package always depends on lofarbase
foreach(_dep ${${_pkg}_DEPENDENCIES})
string(TOLOWER ${_dep} lower_dep_name)
list(APPEND requirements_list "${lower_project_name}-${lower_dep_name}") # the acual inter package depency
endforeach()
list(REMOVE_DUPLICATES requirements_list) # remove any duplicates if present
string(REPLACE ";" "," requirements_string "${requirements_list}") # convert back from list -> string and make it comma seperated
# and finaly store the requirements_string into CPACK_RPM_${lower_parent_pkg}_PACKAGE_REQUIRES so cpack can set the rpm package requirements
set(CPACK_RPM_${lower_parent_pkg}_PACKAGE_REQUIRES ${requirements_string}
CACHE INTERNAL "cpack component-package dependencies for lofar package ${_pkg}") # cache entry is needed, else CPack will not see it.
endif()
# -- end cpack --
# Add all packages that <pkg> depends on to the build. If any of these
# packages are excluded from the build (because BUILD_<dep> is OFF), then
# BUILD_<pkg> will also be set to OFF and an error is raised.
......
# - Create for each LOFAR package a variable containing the absolute path to
# its source directory.
#
# Generated by gen_LofarPackageList_cmake.sh at di 26 nov 2019 10:54:07 CET
# Generated by gen_LofarPackageList_cmake.sh at ma 16 apr 2018 13:39:17 CEST
#
# ---- DO NOT EDIT ----
#
......@@ -172,6 +172,7 @@ if(NOT DEFINED LOFAR_PACKAGE_LIST_INCLUDED)
set(SpecificationServices_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/SpecificationServices)
set(XSD_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/XSD)
set(TBBAlertVOeventPublisher_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/TBBAlertVOeventPublisher)
set(LSMR_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/LSMR)
set(DataManagementCommon_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/DataManagement/DataManagementCommon)
set(StorageQueryService_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/DataManagement/StorageQueryService)
set(Cleanup_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/DataManagement/Cleanup)
......
# - Download and install locally the library using the npm package tool
# npm_install(project.json PUBLIC public_dir SOURCE source_dir DESTINATION install_dir)
# execute npm build in and install the files in the install_dir
# public_dir is the directory where the static files are stored
# source_dir is the directory where the javascript/css files are stored
##
## NPM/REACT Quickstart tutorial
## The tool create-react-app can be used to create a barebone react html/js project.
## This tool can be installed systemwide with npm executing the command '#npm install -g create-react-app'.
## Then, the barebone project setup can be created in the [project-directory] executing the command
## '$create-react-app [project-directory]'
## The script will create the [project-directory], if it doesnt exist, containing the public and src folder and default package.json file,
## it will download the basic dependencies and will start a git repository in the [project-directory].
## However, the file/directories required are only the public and the src directory and the package.json file.
## PLEASE MAKE SURE TO COPY ONLY THOSE FILES/DIRECTORIES IN THE LOFAR SRC TREE!
## Finally, the cmake file for the project has to contains these two lines to make the LOFAR cmake setup build the project
## 'include(NPMInstall)'
## 'npm_install([package.json file] PUBLIC [public directory] SOURCE [source directory] DESTINATION [install destination folder])'
# Copyright (C) 2008-2009
# ASTRON (Netherlands Foundation for Research in Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, softwaresupport@astron.nl
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: PythonInstall.cmake 32905 2015-11-17 15:31:54Z schaap $
find_package(NPM)
function(extract_relative_path OUTPUT_FILE_LIST BASE_PATH ARGC)
set(OUTPUT "")
foreach(FILE ${ARGC})
file(RELATIVE_PATH RELPATH ${BASE_PATH} "${FILE}")
list(APPEND OUTPUT "${RELPATH}")
endforeach(FILE)
set(${OUTPUT_FILE_LIST} ${OUTPUT} PARENT_SCOPE)
endfunction(extract_relative_path)
function(append_basepath_to_file OUTPUT_FILE_LIST BASE_PATH ARGC)
set(OUTPUT "")
foreach(FILE ${ARGC})
set(ITEM "${BASE_PATH}/${FILE}")
list(APPEND OUTPUT "${ITEM}")
endforeach(FILE)
set(${OUTPUT_FILE_LIST} ${OUTPUT} PARENT_SCOPE)
endfunction(append_basepath_to_file)
#
# function npm_install
#
function(npm_install NPM_PACKAGE_SPECIFICATION)
# Precondition check.
if(NOT NPM_EXECUTABLE)
message(FATAL_ERROR "npm_install: cannot find npm")
endif(NOT NPM_EXECUTABLE)
# Parsing arguments
set(one_value_arguments PUBLIC SOURCE DESTINATION)
## syntax is cmake_parse_arguments(prefix options one_value_arguments multi_value_arguments arguments_to_be_parsed)
cmake_parse_arguments(NPM_INSTALL "" "${one_value_arguments}" "" ${ARGN} )
# Checks if all the required arguments have been specified
if(NOT NPM_INSTALL_PUBLIC)
message(FATAL_ERROR "specify public directory.\n ex npm_install(project.json PUBLIC public_dir SOURCE source_dir DESTINATION install_dir)")
endif(NOT NPM_INSTALL_PUBLIC)
if(NOT NPM_INSTALL_SOURCE)
message(FATAL_ERROR "specify source directory.\n ex npm_install(project.json PUBLIC public_dir SOURCE source_dir DESTINATION install_dir)")
endif(NOT NPM_INSTALL_SOURCE)
# Compute the full path to the source, and the public directory, and the json spec
get_filename_component(WEBSITE_PUBLIC_DIR "${NPM_INSTALL_PUBLIC}" REALPATH)
get_filename_component(WEBSITE_SOURCE_DIR "${NPM_INSTALL_SOURCE}" REALPATH)
get_filename_component(JSON_PACKAGE_SPECIFICATION "${NPM_PACKAGE_SPECIFICATION}" REALPATH)
get_filename_component(NPM_BINARY_DIR "${NPM_BINARY_DIR}" REALPATH)
# Checks if the directories public and source are actually present in the disk
if(EXISTS WEBSITE_PUBLIC_DIR)
message(FATAL_ERROR "public directory \"${NPM_INSTALL_PUBLIC}\" cannot be found.")
endif(EXISTS WEBSITE_PUBLIC_DIR)
if(EXISTS WEBSITE_SOURCE_DIR)
message(FATAL_ERROR "source directory \"${NPM_INSTALL_SOURCE}\" cannot be found.")
endif(EXISTS WEBSITE_SOURCE_DIR)
get_filename_component(NPM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" REALPATH)
file(GLOB_RECURSE SOURCE_FILES_PATH ${WEBSITE_SOURCE_DIR} "${WEBSITE_SOURCE_DIR}/*")
file(GLOB_RECURSE PUBLIC_FILES_PATH ${WEBSITE_PUBLIC_DIR} "${WEBSITE_PUBLIC_DIR}/*")
extract_relative_path(SOURCE_FILES ${WEBSITE_SOURCE_DIR} "${SOURCE_FILES_PATH}")
extract_relative_path(PUBLIC_FILES ${WEBSITE_PUBLIC_DIR} "${PUBLIC_FILES_PATH}")
append_basepath_to_file(INSTALLED_SOURCE_FILES "${NPM_BINARY_DIR}/src" "${SOURCE_FILES}")
append_basepath_to_file(INSTALLED_PUBLIC_FILES "${NPM_BINARY_DIR}/public" "${PUBLIC_FILES}")
add_custom_command(
OUTPUT "${NPM_BINARY_DIR}/package.json"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${JSON_PACKAGE_SPECIFICATION}" "${NPM_BINARY_DIR}/package.json"
DEPENDS ${JSON_PACKAGE_SPECIFICATION}
COMMENT "Copying ${JSON_PACKAGE_SPECIFICATION} to ${NPM_BINARY_DIR}/package.json for ${PACKAGE_NAME}")
foreach(file ${SOURCE_FILES})
add_custom_command(OUTPUT "${NPM_BINARY_DIR}/src/${file}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${WEBSITE_SOURCE_DIR}/${file} ${NPM_BINARY_DIR}/src/${file}
DEPENDS "${WEBSITE_SOURCE_DIR}/${file}"
COMMENT "Copying file from ${WEBSITE_SOURCE_DIR}/${file} to ${NPM_BINARY_DIR}/src/${file}")
endforeach(file)
add_custom_command(OUTPUT "${NPM_BINARY_DIR}/.env"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/.env" "${NPM_BINARY_DIR}/.env"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/.env"
COMMENT "Copying enviroment file")
foreach(file ${PUBLIC_FILES})
add_custom_command(OUTPUT "${NPM_BINARY_DIR}/public/${file}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${WEBSITE_PUBLIC_DIR}/${file}" "${NPM_BINARY_DIR}/public/${file}"
DEPENDS "${WEBSITE_PUBLIC_DIR}/${file}"
COMMENT "Copying file from ${WEBSITE_PUBLIC_DIR}/${file} to ${NPM_BINARY_DIR}/src/${file}")
endforeach(file)
add_custom_target(copy_package_json_${PACKAGE_NAME} SOURCES "${JSON_PACKAGE_SPECIFICATION}")
add_custom_target(download_npm_dependencies_${PACKAGE_NAME} SOURCES "${NPM_BINARY_DIR}/package.json")
add_custom_target(packing_javascript_files_${PACKAGE_NAME} ALL
SOURCES ${INSTALLED_SOURCE_FILES} ${INSTALLED_PUBLIC_FILES} "${NPM_BINARY_DIR}/node_modules" "${NPM_BINARY_DIR}/package-lock.json" ${NPM_BINARY_DIR}/.env)
add_custom_target(start_development_server_${PACKAGE_NAME}
SOURCES "${NPM_BINARY_DIR}/node_modules" "${NPM_BINARY_DIR}/package-lock.json" "${NPM_BINARY_DIR}/package.json" ${NPM_BINARY_DIR}/.env
COMMENT "Start start_development_server for ${PACKAGE_NAME}")
add_custom_command(
OUTPUT "${NPM_BINARY_DIR}/src"
COMMAND ${CMAKE_COMMAND} -E make_directory ${NPM_BINARY_DIR}/src
COMMENT "Creating javascript src directory in ${NPM_BINARY_DIR}/src for ${PACKAGE_NAME}")
add_custom_command(
OUTPUT "${NPM_BINARY_DIR}/public"
COMMAND ${CMAKE_COMMAND} -E make_directory ${NPM_BINARY_DIR}/public
COMMENT "Creating public directory ${NPM_BINARY_DIR}/public for ${PACKAGE_NAME}")
add_custom_command(
OUTPUT "${NPM_BINARY_DIR}/.env"
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/.env ${NPM_BINARY_DIR}/.env
COMMENT "Copying enviroment file")
add_custom_command(
OUTPUT "${NPM_BINARY_DIR}/node_modules" "${NPM_BINARY_DIR}/package-lock.json"
COMMAND npm install
DEPENDS "${NPM_BINARY_DIR}/package.json"
WORKING_DIRECTORY "${NPM_BINARY_DIR}"
COMMENT "Downloading npm dependencies for ${NPM_BINARY_DIR}/package.json")
add_custom_command(
TARGET start_development_server_${PACKAGE_NAME}
COMMAND npm start
DEPENDS ${INSTALLED_SOURCE_FILES} ${INSTALLED_PUBLIC_FILES}
WORKING_DIRECTORY "${NPM_BINARY_DIR}"
COMMENT "Starting development server for ${PACKAGE_NAME}")
add_custom_command(
TARGET packing_javascript_files_${PACKAGE_NAME}
COMMAND npm run build
DEPENDS "${INSTALLED_SOURCE_FILES}" "${INSTALLED_PUBLIC_FILES}"
WORKING_DIRECTORY "${NPM_BINARY_DIR}"
COMMENT "Packing javascript files for ${PACKAGE_NAME} into ${NPM_BINARY_DIR}/build for deployment")
install(DIRECTORY ${NPM_BINARY_DIR}/build/ DESTINATION ${NPM_INSTALL_DESTINATION})
endfunction(npm_install)
......@@ -101,6 +101,8 @@ macro(python_install)
set(_inst_dir "${PYTHON_INSTALL_DIR}/${_dest_dir}")
set(_build_dir "${PYTHON_BUILD_DIR}/${_dest_dir}")
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
# Install and byte-compile each Python file.
foreach(_py ${_py_files})
get_filename_component(_py_path ${_py} PATH)
......@@ -117,7 +119,9 @@ macro(python_install)
file(MAKE_DIRECTORY ${_build_dir}/${_py_path})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_py_abs} ${_build_dir}/${_py})
install(${INSTALL_TYPE} ${_py_abs} DESTINATION ${_inst_dir}/${_py_path})
install(${INSTALL_TYPE} ${_py_abs}
DESTINATION ${_inst_dir}/${_py_path}
COMPONENT ${lower_package_name})
if(USE_PYTHON_COMPILATION)
set(_py_code
"import py_compile, os"
......@@ -126,10 +130,11 @@ macro(python_install)
"py_compile.compile('%s${DESTDIR}${_inst_dir}/${_py}' % destdir, doraise=True)")
install(CODE
"execute_process(COMMAND ${PYTHON_EXECUTABLE} -c \"${_py_code}\"
RESULT_VARIABLE _result)
if(NOT _result EQUAL 0)
message(FATAL_ERROR \"Byte-compilation FAILED: \$ENV{DESTDIR}${_inst_dir}/${_py}\")
endif(NOT _result EQUAL 0)")
RESULT_VARIABLE _result)
if(NOT _result EQUAL 0)
message(FATAL_ERROR \"Byte-compilation FAILED: \$ENV{DESTDIR}${_inst_dir}/${_py}\")
endif(NOT _result EQUAL 0)"
COMPONENT ${lower_package_name})
endif(USE_PYTHON_COMPILATION)
endforeach(_py ${_py_files})
......@@ -142,7 +147,8 @@ macro(python_install)
"${PYTHON_BUILD_DIR}${_init_dir}/__init__.py")
install(CODE
"execute_process(COMMAND ${CMAKE_COMMAND} -E touch
\"\$ENV{DESTDIR}${PYTHON_INSTALL_DIR}${_init_dir}/__init__.py\")")
\"\$ENV{DESTDIR}${PYTHON_INSTALL_DIR}${_init_dir}/__init__.py\")"
COMPONENT ${lower_package_name})
endforeach(_dir ${_dir_list})
endmacro(python_install)
......@@ -45,3 +45,9 @@ include(LofarDoxygen)
## Generate configuration header file.
## ---------------------------------------------------------------------------
include(LofarConfig)
## ---------------------------------------------------------------------------
## Setup packaging with CPack
## ---------------------------------------------------------------------------
include(LofarCPack)
......@@ -34,6 +34,8 @@ set(DOCKER_TEMPLATE_DIRS
lofar_add_bin_scripts(docker-template)
lofar_add_sbin_scripts(docker-build-all.sh)
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
# Convert Dockerfile.tmpl -> Dockerfile in ${DOCKER_TEMPLATE_DIRS}
foreach(_dir ${DOCKER_TEMPLATE_DIRS})
# _src -> _dst
......@@ -53,6 +55,7 @@ foreach(_dir ${DOCKER_TEMPLATE_DIRS})
install(FILES
${_dst}
DESTINATION share/docker/${_dir}
COMPONENT ${lower_package_name}
RENAME Dockerfile
)
endforeach()
......@@ -67,5 +70,6 @@ install(DIRECTORY
lofar-subbandtbbwriter
lofar-tbbwriter
DESTINATION share/docker
COMPONENT ${lower_package_name}
USE_SOURCE_PERMISSIONS
PATTERN Dockerfile.tmpl EXCLUDE)
......@@ -5,6 +5,8 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME})
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
# Install header files.
install(FILES
Allocator.h
......@@ -80,18 +82,21 @@ install(FILES
TypeNames.h
TypeNames.tcc
Version.h
DESTINATION include/${PACKAGE_NAME})
DESTINATION include/${PACKAGE_NAME}
COMPONENT ${lower_package_name})
install(FILES
Net/FdSet.h
Net/Socket.h
DESTINATION include/${PACKAGE_NAME}/Net)
DESTINATION include/${PACKAGE_NAME}/Net
COMPONENT ${lower_package_name})
install(FILES
shmem/segbasemap.h
shmem/dlmalloc.h
shmem/shmem_alloc.h
DESTINATION include/${PACKAGE_NAME}/shmem)
DESTINATION include/${PACKAGE_NAME}/shmem
COMPONENT ${lower_package_name})
install(FILES
Thread/Barrier.h
......@@ -102,4 +107,5 @@ install(FILES
Thread/Sem_t.h
Thread/Semaphore.h
Thread/Thread.h
DESTINATION include/${PACKAGE_NAME}/Thread)
DESTINATION include/${PACKAGE_NAME}/Thread
COMPONENT ${lower_package_name})
......@@ -5,6 +5,8 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME})
string(TOLOWER ${PACKAGE_NAME} lower_package_name)
# Install header files.
install(FILES
Exceptions.h
......@@ -15,12 +17,14 @@ install(FILES
ToBus.h
Util.h
XMLDoc.h
DESTINATION include/${PACKAGE_NAME})
DESTINATION include/${PACKAGE_NAME}
COMPONENT ${lower_package_name})
install(FILES
Protocols/TaskFeedbackDataproducts.h
Protocols/TaskFeedbackProcessing.h
Protocols/TaskFeedbackState.h
Protocols/TaskSpecificationSystem.h
DESTINATION include/${PACKAGE_NAME}/Protocols)
DESTINATION include/${PACKAGE_NAME}/Protocols
COMPONENT ${lower_package_name})
......@@ -33,9 +33,15 @@ __all__ = ["Credentials", "DBCredentials", "options_group", "parse_options"]
# obtain the environment, and add USER and HOME if needed (since supervisord does not)
environ = os.environ
user_info = pwd.getpwuid(os.getuid())
environ.setdefault("HOME", user_info.pw_dir)
environ.setdefault("USER", user_info.pw_name)
try:
# Throws a KeyError if user info is not found in /etc/passwd (f.e. in Docker envi