Skip to content
Snippets Groups Projects
Commit 3dd1862e authored by Mattia Mancini's avatar Mattia Mancini
Browse files

OSB-6: added target install to cmake file

parent f93b0ad3
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
......@@ -58,44 +58,61 @@ function(npm_install NPM_PACKAGE_SPECIFICATION)
get_filename_component(JSON_PACKAGE_SPECIFICATION "${NPM_PACKAGE_SPECIFICATION}" REALPATH)
# Checks if the directories public and source are actually present in the disk
if(WEBSITE_PUBLIC_DIR MATCHES "^$")
if(EXISTS WEBSITE_PUBLIC_DIR)
message(FATAL_ERROR "public directory \"${NPM_INSTALL_PUBLIC}\" cannot be found.")
endif(WEBSITE_PUBLIC_DIR MATCHES "^$")
endif(EXISTS WEBSITE_PUBLIC_DIR)
if(WEBSITE_SOURCE_DIR MATCHES "^$")
message(FATAL_ERROR "source directory \"${NPM_INSTALL_PUBLIC}\" cannot be found.")
endif(WEBSITE_SOURCE_DIR MATCHES "^$")
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)
add_custom_target(copy_src_public ALL SOURCES 'public' 'src' COMMENT "Copying src and public directory into build directory")
add_custom_target(download_npm_dependencies ALL SOURCES node_modules package-lock.json DEPENDS copy_src_public COMMENT "Attempt downloading of required npm dependencies")
add_custom_target(copy_src_public ALL SOURCES "public" "src" COMMENT "Copying src and public directory into build directory")
add_custom_target(download_npm_dependencies ALL SOURCES "node_modules" "package-lock.json" DEPENDS copy_src_public COMMENT "Attempt downloading of required npm dependencies")
add_custom_target(packing_javascript_files ALL SOURCES build COMMENT "Attempt packing of javascript files")
add_custom_target(start_development_server_${PACKAGE_NAME} SOURCES "node_modules" "package-lock.json" COMMENT "Start start_development_server for ${PACKAGE_NAME}")
add_custom_command(
OUTPUT 'package.json'
OUTPUT "package.json"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${JSON_PACKAGE_SPECIFICATION} ${NPM_BINARY_DIR}/package.json
COMMENT "Copying package.json")
add_custom_command(
OUTPUT 'src'
OUTPUT "src"
COMMAND ${CMAKE_COMMAND} -E copy_directory
${WEBSITE_SOURCE_DIR} ${NPM_BINARY_DIR}/src
COMMENT "Copying javascript src directory")
add_custom_command(
OUTPUT 'public'
OUTPUT "public"
COMMAND ${CMAKE_COMMAND} -E copy_directory
${WEBSITE_PUBLIC_DIR} ${NPM_BINARY_DIR}/public
COMMENT "Copying public directory")
add_custom_command(
OUTPUT node_modules package-lock.json
OUTPUT "node_modules" "package-lock.json"
COMMAND npm install
DEPENDS 'package.json'
DEPENDS "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
WORKING_DIRECTORY ${NPM_BINARY_DIR}
COMMENT "Starting development server")
add_custom_command(
OUTPUT "build"
COMMAND npm run build
DEPENDS copy_src_public download_npm_dependencies
COMMENT "Packing javascript files for deploy")
message(${NPM_INSTALL_DESTINATION})
install(DIRECTORY ${NPM_BINARY_DIR}/build/ DESTINATION ${NPM_INSTALL_DESTINATION})
endfunction(npm_install)
@import "lofar-variables";
@import "node_modules/bootstrap/scss/bootstrap";
@import "lofar-styles";
@import "lofar-variables.scss";
@import "node_modules/bootstrap/scss/bootstrap.scss";
@import "lofar-styles.scss";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment