From 829abfda01079ff1fbeab07ec3cd690661c9f578 Mon Sep 17 00:00:00 2001 From: Daniele Rapetti Date: Thu, 7 Sep 2023 15:55:21 +0200 Subject: [PATCH 1/5] starting to add the fortran compilation --- fortran/CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 7da53c633f..81773a9d87 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -1,6 +1,16 @@ +cmake_minimum_required(VERSION 3.20.2) +#Thi directory can be compiled as an autonomos project install( FILES plumed_f08.f90 plumed.f90 - DESTINATION ${CMAKE_INSTALL_LIBDIR}/${program_name}/fortran + DESTINATION ${DIRS_EXTRA_INSTALL}/fortran PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ -) \ No newline at end of file +) +include(CheckLanguage) +check_language(Fortran) +if(NOT CMAKE_Fortran_COMPILER) + message(STATUS "Fortran targets will not be compiled") + return() +endif() + +project(Plumed2Fortran LANGUAGES CXX Fortran) From fa3ace4b02770988c0eaf2a12181dbb13b7b33dc Mon Sep 17 00:00:00 2001 From: Daniele Rapetti Date: Fri, 8 Sep 2023 11:14:52 +0200 Subject: [PATCH 2/5] set up few checks for the future --- src/cmake/CMakeLists.txt | 10 ++++++---- src/cmake/PlumedConfig.cmake.in | 13 +++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/cmake/CMakeLists.txt b/src/cmake/CMakeLists.txt index d5c3b3cb7b..3618a47015 100644 --- a/src/cmake/CMakeLists.txt +++ b/src/cmake/CMakeLists.txt @@ -55,10 +55,12 @@ configure_package_config_file( PlumedConfig.cmake.in Plumed2Config.cmake INSTALL_DESTINATION - ${DIRS_CMAKE_INSTALL} - PATH_VARS DIRS_INCLUDE_INSTALL - DIRS_LIB_INSTALL - DIRS_BIN_INSTALL + ${DIRS_CMAKE_INSTALL} + PATH_VARS + DIRS_INCLUDE_INSTALL + DIRS_LIB_INSTALL + DIRS_BIN_INSTALL + DIRS_EXTRA_INSTALL ) ################################################################################ diff --git a/src/cmake/PlumedConfig.cmake.in b/src/cmake/PlumedConfig.cmake.in index 415bc3478f..a1a2dbebc8 100644 --- a/src/cmake/PlumedConfig.cmake.in +++ b/src/cmake/PlumedConfig.cmake.in @@ -14,9 +14,18 @@ include("${CMAKE_CURRENT_LIST_DIR}/Plumed2EXEC.cmake") #user macros are included in this .cmake include("${CMAKE_CURRENT_LIST_DIR}/PlumedUserMacros.cmake") +#TODO: set up the build dir to work with these +# set_and_check(Plumed2_INCLUDE_DIR "@PACKAGE_DIRS_INCLUDE_INSTALL@") #set_and_check(Plumed2_INCLUDE_DIR "@PACKAGE_DIRS_INCLUDE_INSTALL@") -#set_and_check(Plumed2_LIB_DIR "@PACKAGE_DIRS_LIB_INSTALL@") -#set_and_check(Plumed2_BIN_DIR "@PACKAGE_DIRS_BIN_INSTALL@") +# set_and_check(Plumed2_LIB_DIR "@PACKAGE_DIRS_LIB_INSTALL@") +# set_and_check(Plumed2_BIN_DIR "@PACKAGE_DIRS_BIN_INSTALL@") +# set_and_check(Plumed2_EXTRA_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@") +# set_and_check(Plumed2_FORTRAN_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/fortran") +# set_and_check(Plumed2_VIM_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/vim") +# set_and_check(Plumed2_SCRIPTS_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/scripts") +# set_and_check(Plumed2_PATCHES_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/patches") +set(Plumed2_FORTRAN "@PACKAGE_DIRS_EXTRA_INSTALL@/fortran/plumed.f90") +set(Plumed2_FORTRAN08 "@PACKAGE_DIRS_EXTRA_INSTALL@/fortran/plumed_f08.f90") set(Plumed2_DIR "${CMAKE_CURRENT_LIST_DIR}") From 7a93c55b5eea479d87881b4a17eaef1050ce57e6 Mon Sep 17 00:00:00 2001 From: Daniele Rapetti Date: Fri, 8 Sep 2023 16:07:47 +0200 Subject: [PATCH 3/5] now the make test works --- fortran/CMakeLists.txt | 9 +- regtest/CMakeLists.txt | 19 +++- regtest/basic/rt-make-c11/CMakeLists.txt | 1 + regtest/basic/rt-make-fortran/CMakeLists.txt | 1 + .../basic/rt-make-fortran08/CMakeLists.txt | 1 + regtest/scripts/run_ctest | 86 ++++++++++++++++++- src/cmake/CMakeLists.txt | 29 +++++-- 7 files changed, 131 insertions(+), 15 deletions(-) diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 81773a9d87..aa07d554ac 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -6,11 +6,16 @@ install( FILES plumed_f08.f90 plumed.f90 OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) + +file(COPY plumed_f08.f90 plumed.f90 +DESTINATION ${CMAKE_BINARY_DIR}/lib/plumed/fortran +USE_SOURCE_PERMISSIONS +) include(CheckLanguage) check_language(Fortran) if(NOT CMAKE_Fortran_COMPILER) - message(STATUS "Fortran targets will not be compiled") + message(STATUS "Fortran cannot be compiled") return() endif() -project(Plumed2Fortran LANGUAGES CXX Fortran) +#project(Plumed2Fortran LANGUAGES CXX Fortran) diff --git a/regtest/CMakeLists.txt b/regtest/CMakeLists.txt index 4a72acf531..1b98bdd0c2 100644 --- a/regtest/CMakeLists.txt +++ b/regtest/CMakeLists.txt @@ -12,7 +12,7 @@ if(NOT TARGET Plumed2::plumed_bin) #when testing in the build environment set(STANDALONE_TESTS ON) else() - set (Plumed2_DIR "${CMAKE_BINARY_DIR}/src/cmake") + set (Plumed2_DIR "${CMAKE_BINARY_DIR}/lib/cmake/plumed") endif() set(PLUMED_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -20,6 +20,7 @@ set(run_ctest ${CMAKE_CURRENT_SOURCE_DIR}/scripts/run_ctest) #set (failRegex "FAILURE;ERROR;WARNING") set (failRegex "FAILURE;ERROR") +set (skipRegex "NOT_APPLICABLE") set(PLUMED_TEST_KNOWN_TYPES simplemd @@ -39,6 +40,7 @@ function(PLUMED_TEST test_name) #[EXPORTVARIABLES variable1 value1 variable2 value2 ...] #[NEEDS component1 component2 ...] #[MODULES module1 module2 ...] + #[COMPILER_LANGUAGE C11 or Fortran08] #[LABELS label1 label2 ...] #) @@ -67,13 +69,15 @@ function(PLUMED_TEST test_name) # #With EXTRAFILES the user can specify a list of paths to files to be copied in the test directory # - # #With NEEDS the user can specify a list needed components, if the specified #componets are not found by `plumed config has componentname` the test will be skipped. # #With MODULES the user can specify a list needed modules, if the specified #componets are not found by `plumed config module modulename` the test will be skipped. # + #With COMPILER_LANGUAGE you can specify Fortan08 or C11 and the make test will be skipped if the compiler is not compatible (works ONLY + #for make tests), note the argments are case insensitive + # #With LABELS the user can specify a collection of keyword that can be use to #limit the number of test to be runned with ctest. The type and the home #directory of the test are automatically set up as labels @@ -82,7 +86,7 @@ function(PLUMED_TEST test_name) # will be automatically prepended to the specified arguments set(options "") - set(oneValueArgs "TYPE;ARGS;MPIPROCS") + set(oneValueArgs "TYPE;ARGS;MPIPROCS;COMPILER_LANGUAGE") set(multiValueArgs "EXTRAFILES;EXPORTVARIABLES;NEEDS;LABELS;MODULES") cmake_parse_arguments(PARSE_ARGV 1 PLUMED_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ) @@ -108,6 +112,13 @@ function(PLUMED_TEST test_name) if(PLUMED_TEST_MPIPROCS) set(PLUMED_TEST_MPIPROCS "-p${PLUMED_TEST_MPIPROCS}") endif() + + if(PLUMED_TEST_COMPILER_LANGUAGE) + string(TOLOWER ${PLUMED_TEST_COMPILER_LANGUAGE} PLUMED_TEST_COMPILER_LANGUAGE) + set(PLUMED_TEST_COMPILER_LANGUAGE "-c${PLUMED_TEST_COMPILER_LANGUAGE}") + endif() + + if(PLUMED_TEST_EXTRAFILES) set (t) foreach(extra IN LISTS PLUMED_TEST_EXTRAFILES) @@ -163,6 +174,7 @@ function(PLUMED_TEST test_name) -d${CMAKE_CURRENT_SOURCE_DIR} ${PLUMED_TEST_MPIPROCS} ${PLUMED_TEST_EXTRAFILES} + ${PLUMED_TEST_COMPILER_LANGUAGE} ${nopt} ${PLUMED_TEST_NEEDS} ${mopt} ${PLUMED_TEST_MODULES} ${PLUMED_TEST_EXPORTVARIABLES} @@ -180,6 +192,7 @@ function(PLUMED_TEST test_name) set_tests_properties(${testname} PROPERTIES FAIL_REGULAR_EXPRESSION "${failRegex}" + SKIP_REGULAR_EXPRESSION "${skipRegex}" SKIP_RETURN_CODE 125 LABELS "${PLUMED_TEST_LABELS}") endfunction(PLUMED_TEST) diff --git a/regtest/basic/rt-make-c11/CMakeLists.txt b/regtest/basic/rt-make-c11/CMakeLists.txt index 8954528115..1e2f15405f 100644 --- a/regtest/basic/rt-make-c11/CMakeLists.txt +++ b/regtest/basic/rt-make-c11/CMakeLists.txt @@ -1,6 +1,7 @@ PLUMED_TEST(rt-make-c11 TYPE make EXPORTVARIABLES PLUMED_STACK_TRACE "no" +COMPILER_LANGUAGE C11 ) #the following variable is the original config file set(originalConfig [[ diff --git a/regtest/basic/rt-make-fortran/CMakeLists.txt b/regtest/basic/rt-make-fortran/CMakeLists.txt index bab165abf6..48466bb98c 100644 --- a/regtest/basic/rt-make-fortran/CMakeLists.txt +++ b/regtest/basic/rt-make-fortran/CMakeLists.txt @@ -1,4 +1,5 @@ PLUMED_TEST(rt-make-fortran TYPE make +COMPILER_LANGUAGE Fortran ) #the following variable is the original config file set(originalConfig [[ diff --git a/regtest/basic/rt-make-fortran08/CMakeLists.txt b/regtest/basic/rt-make-fortran08/CMakeLists.txt index 5315b83cf3..7b5e9c03b5 100644 --- a/regtest/basic/rt-make-fortran08/CMakeLists.txt +++ b/regtest/basic/rt-make-fortran08/CMakeLists.txt @@ -1,6 +1,7 @@ PLUMED_TEST(rt-make-fortran08 TYPE make EXPORTVARIABLES PLUMED_STACK_TRACE "no" +COMPILER_LANGUAGE Fortran08 ) #the following variable is the original config file set(originalConfig [[ diff --git a/regtest/scripts/run_ctest b/regtest/scripts/run_ctest index e946d20ebf..3730de67f6 100755 --- a/regtest/scripts/run_ctest +++ b/regtest/scripts/run_ctest @@ -185,18 +185,96 @@ run_make() { files=$(ls ./*.cpp ./*.f90 ./*.c 2>/dev/null) if [[ -n ${filesf90} ]]; then otherLang="${otherLang}enable_language (Fortran)\n" + if [[ $compiler_language = "fortran08" ]]; then + otherLang=$( + cat <CMakeLists.txt cmake_minimum_required(VERSION 3.20) project(exe-test CXX) $(echo -e "$otherLang") find_package(Plumed2 REQUIRED) +$(echo -e "$compileLibs") add_executable(exe ${files}) target_link_libraries(exe PUBLIC - Plumed2::sharedplumedMain + Plumed2::sharedplumedMain $otherLibs #automatically links to the shared kernel Plumed2::sharedplumedKernel ) install (TARGETS exe @@ -275,13 +353,14 @@ set -o pipefail plumed_needs="" extra_files=() valgrind="env" - - while getopts "a:d:e:f:l:m:n:p:v" option; do + + while getopts "a:c:d:e:f:l:m:n:p:v" option; do #echo "$option -> ${OPTARG}" case "$option" in #the a) args=${OPTARG} ;; #the directory with the source of the test + c) compiler_language=${OPTARG} ;; d) dir=${OPTARG} ;; e) name=${OPTARG%=*} @@ -323,6 +402,7 @@ EOF export args export plumed_modules export plumed_needs + export compiler_language export extra_files export valgind export plumed diff --git a/src/cmake/CMakeLists.txt b/src/cmake/CMakeLists.txt index 3618a47015..261d206cb3 100644 --- a/src/cmake/CMakeLists.txt +++ b/src/cmake/CMakeLists.txt @@ -50,11 +50,11 @@ if(BoostCompontents) endif() list(JOIN EXTERNAL_PACKAGES "\n" EXTERNAL_PACKAGES) - +#this is the installed version configure_package_config_file( PlumedConfig.cmake.in - Plumed2Config.cmake - INSTALL_DESTINATION + "Plumed2Config.cmake" + INSTALL_DESTINATION ${DIRS_CMAKE_INSTALL} PATH_VARS DIRS_INCLUDE_INSTALL @@ -62,25 +62,39 @@ configure_package_config_file( DIRS_BIN_INSTALL DIRS_EXTRA_INSTALL ) +#This is the build version +configure_package_config_file( + PlumedConfig.cmake.in + "${CMAKE_BINARY_DIR}/lib/cmake/plumed/Plumed2Config.cmake" + INSTALL_DESTINATION + ${CMAKE_BINARY_DIR}/lib/cmake/plumed/ + PATH_VARS + DIRS_INCLUDE_INSTALL + DIRS_LIB_INSTALL + DIRS_BIN_INSTALL + DIRS_EXTRA_INSTALL + INSTALL_PREFIX + ${CMAKE_BINARY_DIR} +) ################################################################################ ######################Creating Plumed2ConfigVersion.cmake####################### ################################################################################ -write_basic_package_version_file(Plumed2ConfigVersion.cmake +write_basic_package_version_file("${CMAKE_BINARY_DIR}/lib/cmake/plumed/Plumed2ConfigVersion.cmake" VERSION ${PLUMED_VERSION_MAJOR}.${PLUMED_VERSION_MINOR}.${PLUMED_VERSION_PATCH} #COMPATIBILITY COMPATIBILITY SameMinorVersion ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Plumed2Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/Plumed2ConfigVersion.cmake + ${CMAKE_BINARY_DIR}/lib/cmake/plumed/Plumed2ConfigVersion.cmake PlumedUserMacros.cmake #This installs the macros for the user DESTINATION ${DIRS_CMAKE_INSTALL} ) #this is needed to have PlumedUserMacros.cmake avaiable in the build configuration file(COPY PlumedUserMacros.cmake - DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + DESTINATION ${CMAKE_BINARY_DIR}/lib/cmake/plumed/ ) foreach(exportetTargets Plumed2MODULES Plumed2WRAPPERS Plumed2LIBS Plumed2EXEC) @@ -90,6 +104,7 @@ foreach(exportetTargets Plumed2MODULES Plumed2WRAPPERS Plumed2LIBS Plumed2EXEC) ) export(EXPORT ${exportetTargets} NAMESPACE Plumed2:: - FILE "${CMAKE_CURRENT_BINARY_DIR}/${exportetTargets}.cmake" + FILE "${CMAKE_BINARY_DIR}/lib/cmake/plumed/${exportetTargets}.cmake" ) endforeach(exportetTargets ) + From c6cc35d064a48ad8a849c5d56c97220fca886c1a Mon Sep 17 00:00:00 2001 From: Daniele Rapetti Date: Fri, 8 Sep 2023 18:43:33 +0200 Subject: [PATCH 4/5] removed the skip condition from the "should fail tests" --- regtest/testIntegrity/checkMODULESFAIL/CMakeLists.txt | 1 + regtest/testIntegrity/checkNEEDS/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/regtest/testIntegrity/checkMODULESFAIL/CMakeLists.txt b/regtest/testIntegrity/checkMODULESFAIL/CMakeLists.txt index 10bf5664e7..ff967797b2 100644 --- a/regtest/testIntegrity/checkMODULESFAIL/CMakeLists.txt +++ b/regtest/testIntegrity/checkMODULESFAIL/CMakeLists.txt @@ -9,3 +9,4 @@ set_tests_properties(${TEST_DIR}-checkMODULES_SHOULD_FAIL PROPERTIES WILL_FAIL ON ) set_property(TEST ${TEST_DIR}-checkMODULES_SHOULD_FAIL PROPERTY SKIP_RETURN_CODE) +set_property(TEST ${TEST_DIR}-checkMODULES_SHOULD_FAIL PROPERTY SKIP_REGULAR_EXPRESSION) diff --git a/regtest/testIntegrity/checkNEEDS/CMakeLists.txt b/regtest/testIntegrity/checkNEEDS/CMakeLists.txt index 6e3b690fe9..a5fc8bdac4 100644 --- a/regtest/testIntegrity/checkNEEDS/CMakeLists.txt +++ b/regtest/testIntegrity/checkNEEDS/CMakeLists.txt @@ -6,3 +6,4 @@ set_tests_properties(${TEST_DIR}-checkNEEDS_SHOULD_FAIL PROPERTIES WILL_FAIL ON ) set_property(TEST ${TEST_DIR}-checkNEEDS_SHOULD_FAIL PROPERTY SKIP_RETURN_CODE) +set_property(TEST ${TEST_DIR}-checkNEEDS_SHOULD_FAIL PROPERTY SKIP_REGULAR_EXPRESSION) From c208f896362dd803e5e95d74a2f3f82c7abc4c1d Mon Sep 17 00:00:00 2001 From: Daniele Rapetti Date: Fri, 29 Sep 2023 09:56:52 +0200 Subject: [PATCH 5/5] adding some documentation to make things clearer --- fortran/CMakeLists.txt | 5 ++++- fortran/Makefile | 1 + regtest/scripts/run_ctest | 9 +++++++-- src/cmake/PlumedConfig.cmake.in | 36 ++++++++++++++++++++++++++------- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index aa07d554ac..fb7b4c0dc1 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.20.2) -#Thi directory can be compiled as an autonomos project +#This directory can be compiled as an autonomos project + +#install file for install-mode plumed install( FILES plumed_f08.f90 plumed.f90 DESTINATION ${DIRS_EXTRA_INSTALL}/fortran PERMISSIONS @@ -7,6 +9,7 @@ install( FILES plumed_f08.f90 plumed.f90 OWNER_READ GROUP_READ WORLD_READ ) +#copy file for build-only plumed file(COPY plumed_f08.f90 plumed.f90 DESTINATION ${CMAKE_BINARY_DIR}/lib/plumed/fortran USE_SOURCE_PERMISSIONS diff --git a/fortran/Makefile b/fortran/Makefile index 3da729e1cf..70719e393f 100644 --- a/fortran/Makefile +++ b/fortran/Makefile @@ -1,3 +1,4 @@ +#To the developer: use this simple makefile to generate the fortran interfaces all: plumed.f90 plumed_f08.f90 plumed.f90: plumed.f90.template diff --git a/regtest/scripts/run_ctest b/regtest/scripts/run_ctest index 659b0176d8..df93c0c6c3 100755 --- a/regtest/scripts/run_ctest +++ b/regtest/scripts/run_ctest @@ -233,11 +233,16 @@ message (FATAL_ERROR "NOT_APPLICABLE (the compiler is not Fortran08 compatible)" endif() EOF ) - compileLibs="${compileLibs}add_library (PlumedFortran08 \${Plumed2_FORTRAN08})\n" - otherLibs="${otherLibs} PlumedFortran08" + #alternative sligthly more complex way + #compileLibs="${compileLibs}add_library (PlumedFortran08)\n" + #otherLibs="${otherLibs} PlumedFortran08" + files="${files} \${Plumed2_FORTRAN08}" else + # TODO maybe test both the compile methods for 08 and non 08 fortran + #alternative sligthly more complex way commented compileLibs="${compileLibs}add_library (PlumedFortran \${Plumed2_FORTRAN})\n" otherLibs="${otherLibs} PlumedFortran" + # files="${files} \${Plumed2_FORTRAN}" fi fi if [[ -n ${filesC} ]]; then diff --git a/src/cmake/PlumedConfig.cmake.in b/src/cmake/PlumedConfig.cmake.in index a1a2dbebc8..b8e0c89162 100644 --- a/src/cmake/PlumedConfig.cmake.in +++ b/src/cmake/PlumedConfig.cmake.in @@ -14,18 +14,40 @@ include("${CMAKE_CURRENT_LIST_DIR}/Plumed2EXEC.cmake") #user macros are included in this .cmake include("${CMAKE_CURRENT_LIST_DIR}/PlumedUserMacros.cmake") -#TODO: set up the build dir to work with these +#TODO: set up the build dir to work with these in build-only mode # set_and_check(Plumed2_INCLUDE_DIR "@PACKAGE_DIRS_INCLUDE_INSTALL@") -#set_and_check(Plumed2_INCLUDE_DIR "@PACKAGE_DIRS_INCLUDE_INSTALL@") -# set_and_check(Plumed2_LIB_DIR "@PACKAGE_DIRS_LIB_INSTALL@") +set_and_check(Plumed2_LIB_DIR "@PACKAGE_DIRS_LIB_INSTALL@") # set_and_check(Plumed2_BIN_DIR "@PACKAGE_DIRS_BIN_INSTALL@") -# set_and_check(Plumed2_EXTRA_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@") -# set_and_check(Plumed2_FORTRAN_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/fortran") +set_and_check(Plumed2_EXTRA_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@") +set_and_check(Plumed2_FORTRAN_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/fortran") # set_and_check(Plumed2_VIM_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/vim") # set_and_check(Plumed2_SCRIPTS_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/scripts") # set_and_check(Plumed2_PATCHES_DIR "@PACKAGE_DIRS_EXTRA_INSTALL@/patches") -set(Plumed2_FORTRAN "@PACKAGE_DIRS_EXTRA_INSTALL@/fortran/plumed.f90") -set(Plumed2_FORTRAN08 "@PACKAGE_DIRS_EXTRA_INSTALL@/fortran/plumed_f08.f90") + +#TODO: add to the manual: +# To compile a fortran executable with plumed you have (at least) two ways write the CMakeLists.txt: +# Method 1: +# ``` +# cmake_minimum_required(VERSION 3.20) +# project(exe-test CXX Fortran) +# find_package(Plumed2 REQUIRED) +# add_executable(exe main.f9 source.f90 ${Plumed2_FORTRAN}) +# # and then link the wanted plumed library +# target_link_libraries(exe PUBLIC Plumed2::sharedplumedMain) +# ``` +# Method 2: +# ``` +# cmake_minimum_required(VERSION 3.20) +# project(exe-test CXX Fortran) +# find_package(Plumed2 REQUIRED) +# #compiling PlumedFortran as a separated library +# add_library (PlumedFortran ${Plumed2_FORTRAN}) +# add_executable(exe main.f9 source.f90) +# #and linking it to the exe along with the wanted plumed library +# target_link_libraries(exe PUBLIC Plumed2::sharedplumedKernel PlumedFortran) +# ``` +set(Plumed2_FORTRAN "${Plumed2_FORTRAN_DIR}/plumed.f90") +set(Plumed2_FORTRAN08 "${Plumed2_FORTRAN_DIR}/plumed_f08.f90") set(Plumed2_DIR "${CMAKE_CURRENT_LIST_DIR}")