diff --git a/CMakeLists.txt b/CMakeLists.txt index f4f7e51ef..e53f77acd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ if(IS_FEDORA_LIKE) endif(DEFINED ENV{MPI_SUFFIX}) endif(IS_FEDORA_LIKE) -# Set built products location: +# Set the location of the built artifacts: # # - Shared and static library target directory: lib # - Executable target directory: bin @@ -140,23 +140,30 @@ elseif(C11) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() -# Message the current C++ configuration -message(STATUS "CMake generator is: ${CMAKE_GENERATOR}") -message(STATUS "CMake compiler is: ${CMAKE_CXX_COMPILER_ID}") -message(STATUS "CMake C++ standard is: ${CMAKE_CXX_STANDARD}") - # Find Bison/Flex if required if(BUILD_LEX_YACC) find_package(BISON REQUIRED) find_package(FLEX REQUIRED) endif() -# Find Java +# Find Java if required if(BUILD_JARS) find_package(Java REQUIRED COMPONENTS Development) + include(UseJava) + set(KHIOPS_BUILD_JAR_DIR "${CMAKE_BINARY_DIR}/jars") + message(STATUS "Java JARs will be stored at ${KHIOPS_BUILD_JAR_DIR}") + # Note: For final builds we recommend to use java 1.8 to ensure that the jar is compatible with all posterior java + # versions (from # 1.8 to the most recent ones). The following setting accomplish that: + # + # - find_package(Java 1.8 EXACT REQUIRED COMPONENTS Development) endif() -# MSVC: Eliminate some options the old CMake way because VS sets them with default values +# Message the current C++ configuration +message(STATUS "CMake generator is: ${CMAKE_GENERATOR}") +message(STATUS "CMake compiler is: ${CMAKE_CXX_COMPILER_ID}") +message(STATUS "CMake C++ standard is: ${CMAKE_CXX_STANDARD}") + +# MSVC: Eliminate some options the old CMake way because VS sets them with undesired default values # # - the C++ exception flags # - the runtime information flags @@ -288,14 +295,35 @@ function(display_variables) endforeach() endfunction() +# This function set up a JAR target. Arguments: +# +# - NAME: Name of the JAR target +# - IMAGES: Paths of the image files to include in the JAR +function(add_khiops_jar) + # Parse the function arguments + set(options "") + set(oneValueArgs "NAME") + set(multiValueKwargs "JAVA_FILES" "IMAGES") + cmake_parse_arguments(ADD_KHIOPS_JAR "${options}" "${oneValueArgs}" "${multiValueKwargs}" ${ARGN}) + + # Add the JAR target with its resources and install + message(STATUS "Setting up JAR ${ADD_KHIOPS_JAR_NAME}.jar") + add_jar( + "${ADD_KHIOPS_JAR_NAME}_jar" ${ADD_KHIOPS_JAR_JAVA_FILES} + OUTPUT_NAME ${ADD_KHIOPS_JAR_NAME} RESOURCES NAMESPACE "images" ${ADD_KHIOPS_JAR_IMAGES} + OUTPUT_DIR "${CMAKE_BINARY_DIR}/jars") + install_jar("${ADD_KHIOPS_JAR_NAME}_jar" DESTINATION usr/share/khiops) +endfunction() + # Add targets for Norm Parallel and Learning modules add_subdirectory(src/Norm) add_subdirectory(src/Parallel) add_subdirectory(src/Learning) +# Testing settings if(TESTING) + # Disable gMock from the building of googletest set(BUILD_GMOCK OFF) - set(INSTALL_GTEST OFF) # Fetch googletest from its Git repo include(FetchContent) @@ -318,17 +346,19 @@ if(TESTING) set_property(TARGET gtest_main PROPERTY MSVC_RUNTIME_LIBRARY MultiThreadedDebug) endif() + # Include and enable googletest include(GoogleTest) enable_testing() + # Add testing targets add_subdirectory(test/Norm) add_subdirectory(test/Parallel) add_subdirectory(test/Parallel-mpi) add_subdirectory(test/Learning) - endif(TESTING) # Exclude googletest from the installation set(INSTALL_GTEST OFF) +# Add packaging directory for CPack scripts include(packaging) diff --git a/src/Learning/CMakeLists.txt b/src/Learning/CMakeLists.txt index 1a31e56a0..ed09a4c96 100644 --- a/src/Learning/CMakeLists.txt +++ b/src/Learning/CMakeLists.txt @@ -26,24 +26,16 @@ add_subdirectory(SNBPredictor) # build norm.jar if(BUILD_JARS) - include(UseJava) - add_jar( - khiops_jar - OUTPUT_NAME - khiops - RESOURCES - NAMESPACE - "" - ../../packaging/common/images/khiops_coclustering_about.gif - ../../packaging/common/images/khiops_coclustering.gif - ../../packaging/common/images/khiops_about.gif - ../../packaging/common/images/khiops.gif - OUTPUT_DIR ${CMAKE_BINARY_DIR}) - message(STATUS "build khiops.jar in ${CMAKE_BINARY_DIR}") - install_jar( - khiops_jar - DESTINATION usr/share/khiops - COMPONENT KHIOPS) + add_khiops_jar( + NAME + "khiops" + NAMESPACE + "images" + IMAGES + "../../packaging/common/images/khiops_coclustering_about.gif" + "../../packaging/common/images/khiops_coclustering.gif" + "../../packaging/common/images/khiops_about.gif" + "../../packaging/common/images/khiops.gif") endif() include(install) diff --git a/src/Learning/MODL/MDKhiopsLearningProject.cpp b/src/Learning/MODL/MDKhiopsLearningProject.cpp index bc25eb646..a2a417a78 100644 --- a/src/Learning/MODL/MDKhiopsLearningProject.cpp +++ b/src/Learning/MODL/MDKhiopsLearningProject.cpp @@ -27,10 +27,10 @@ void MDKhiopsLearningProject::OpenLearningEnvironnement() KWGrouper::RegisterGrouper(new DTGrouperMODL); // Parametrage de l'icone de l'application - UIObject::SetIconImage("khiops.gif"); + UIObject::SetIconImage("images/khiops.gif"); // Parametrage du menu about - SetLearningAboutImage("khiops_about.gif"); + SetLearningAboutImage("images/khiops_about.gif"); SetLearningWebSite("www.khiops.com"); // Parametrage de la fenetre de documentation diff --git a/src/Learning/MODL_Coclustering/CCLearningProject.cpp b/src/Learning/MODL_Coclustering/CCLearningProject.cpp index a7650dc6f..a4117501e 100644 --- a/src/Learning/MODL_Coclustering/CCLearningProject.cpp +++ b/src/Learning/MODL_Coclustering/CCLearningProject.cpp @@ -23,10 +23,10 @@ void CCLearningProject::OpenLearningEnvironnement() SetLearningModuleName("Coclustering"); // Parametrage de l'icone de l'application - UIObject::SetIconImage("khiops_coclustering.gif"); + UIObject::SetIconImage("images/khiops_coclustering.gif"); // Parametrage du menu about - SetLearningAboutImage("khiops_coclustering_about.gif"); + SetLearningAboutImage("images/khiops_coclustering_about.gif"); SetLearningWebSite("www.khiops.com"); // Parametrage de la fenetre de documentation diff --git a/src/Norm/CMakeLists.txt b/src/Norm/CMakeLists.txt index 8cf380f89..c9dcfe37e 100644 --- a/src/Norm/CMakeLists.txt +++ b/src/Norm/CMakeLists.txt @@ -9,31 +9,19 @@ if(FULL) add_subdirectory(generetest) endif(FULL) -# build norm.jar +# Add norm.jar target if(BUILD_JARS) - # we recommend to use java 1.8 to ensure that the jar is compatible with all java versions (from 1.8 to the most - # recent ones) find_package(Java 1.8 EXACT REQUIRED COMPONENTS Development) - find_package(Java REQUIRED COMPONENTS Development) - - include(UseJava) - file(GLOB_RECURSE javafiles NormGUI/*.java) - add_jar( - norm_jar ${javafiles} - OUTPUT_NAME norm - ENTRY_POINT - normGUI.engine.GUIObject - RESOURCES - NAMESPACE - "images" - NormGUI/images/sample.png - NormGUI/images/sample.jpg - NormGUI/images/sample.gif - NormGUI/images/sample2.png - OUTPUT_DIR ${CMAKE_BINARY_DIR}) - message(STATUS "build norm.jar in ${CMAKE_BINARY_DIR}") - install_jar( - norm_jar - DESTINATION usr/share/khiops - COMPONENT KHIOPS) - + file(GLOB_RECURSE norm_java_files NormGUI/*.java) + add_khiops_jar( + NAME + "norm" + JAVA_FILES + ${norm_java_files} + NAMESPACE + "images" + IMAGES + "NormGUI/images/sample.png" + "NormGUI/images/sample.jpg" + "NormGUI/images/sample.gif" + "NormGUI/images/sample2.png") endif()