diff --git a/CMakeLists.txt b/CMakeLists.txt index af4aaebc723..f887a6d3c82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ set(CMAKE_MODULE_PATH ${CCSE_MODULE_PATH}) include(CCSEOptions) # A property for accumulating the a global CCSE link line. -set_property(GLOBAL PROPERTY AMANZI_LINK_LINE "-L${CMAKE_INSTALL_PREFIX}/lib") +set_property(GLOBAL PROPERTY CCSE_LINK_LINE "-L${CMAKE_INSTALL_PREFIX}/lib") # A property for accumulating CCSE library targets set_property(GLOBAL PROPERTY CCSE_LIBRARY_TARGETS) @@ -58,11 +58,7 @@ add_subdirectory(Src) # Make the exports only _after_ doing the build create_exports() -if (${CCSE_INSTALL_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) -else () - install(FILES ${CCSE_PERL_DIR}/strip72 - DESTINATION ${CCSE_INSTALL_DIR}/perl) -endif () +ADD_INSTALL_PERLSCRIPT(${CCSE_PERL_DIR}/strip72) option(ENABLE_Config_Report "Print out detailed information at the end of a configuration") set(CCSE_CONFIG_LOG "${CCSE_BINARY_DIR}/ccse-config.log" diff --git a/Tools/CMake/InstallManager.cmake b/Tools/CMake/InstallManager.cmake index e04b9e5ba06..02ab7f9fc4f 100644 --- a/Tools/CMake/InstallManager.cmake +++ b/Tools/CMake/InstallManager.cmake @@ -53,6 +53,42 @@ function ( ADD_INSTALL_LIBRARY ) endfunction( ADD_INSTALL_LIBRARY ) +# +# Usage: ADD_INSTALL_SHELLSCRIPT( script1 script2 ... ) +# +# Arguments: +# A list of shell scripts that will be installed in the CCSE_INSTALL_BIN_DIR +# +# +function ( ADD_INSTALL_SHELLSCRIPT ) + +foreach(_shellscript_file ${ARGV}) + install( + FILES ${_shellscript_file} + DESTINATION bin + ) +endforeach() + +endfunction( ADD_INSTALL_SHELLSCRIPT ) + + +# +# Usage: ADD_INSTALL_PERLSCRIPT( script1 script2 ... ) +# +# Arguments: +# A list of perl scripts that will be installed in the CCSE_INSTALL_PERL_DIR +# +# +function ( ADD_INSTALL_PERLSCRIPT ) + +foreach(_perlscript_file ${ARGV}) + install( + FILES ${_perlscript_file} + DESTINATION perl + ) +endforeach() + +endfunction( ADD_INSTALL_PERLSCRIPT ) @@ -77,6 +113,64 @@ endforeach() endfunction( ADD_INSTALL_BINARY ) +# +# Usage: makefile_include_dirs(CMAKE_INCLUDE_LIST in_list +# MAKE_INCLUDE_LIST out_list) +# +# Arguments: +# CMAKE_INCLUDE_LIST List of include directories +# MAKE_INCLUDE_LIST List include directories for make +# +function(makefile_include_dirs) + + cmake_parse_arguments(PARSE_ARGS "" "MAKE_INCLUDE_LIST" "CMAKE_INCLUDE_LIST" ${ARGN}) + #print_variable(PARSE_ARGS_CMAKE_INCLUDE_LIST) + #print_variable(PARSE_ARGS_MAKE_INCLUDE_LIST) + + set(tmp_inc_list) + set(loop_list ${PARSE_ARGS_CMAKE_INCLUDE_LIST}) + list(REMOVE_DUPLICATES loop_list) + foreach( dir ${loop_list}) + set(i_path "-I${dir} ") + list(APPEND tmp_inc_list ${i_path}) + endforeach() + + set(tmp_make_list) + string(REGEX REPLACE ";" "" tmp_make_list ${tmp_inc_list}) + set(${PARSE_ARGS_MAKE_INCLUDE_LIST} "${tmp_make_list}" PARENT_SCOPE) + +endfunction(makefile_include_dirs) + +# +# Usage: makefile_library_dirs(CMAKE_LIB_LIST in_list +# MAKE_LIB_LIST out_list) +# +# Arguments: +# CMAKE_LIB_LIST List of library directories +# MAKE_LIB_LIST List library directories for make +# +function(makefile_library_dirs) + + cmake_parse_arguments(PARSE_ARGS "" "MAKE_LIB_LIST" "CMAKE_LIB_LIST" ${ARGN}) + #print_variable(PARSE_ARGS_CMAKE_LIB_LIST) + #print_variable(PARSE_ARGS_MAKE_LIB_LIST) + + set(tmp_lib_list) + set(loop_list ${PARSE_ARGS_CMAKE_LIB_LIST}) + list(REVERSE loop_list) + list(REMOVE_DUPLICATES loop_list) + list(REVERSE loop_list) + foreach( dir ${loop_list}) + set(l_path "-L${dir} ") + list(APPEND tmp_lib_list ${l_path}) + endforeach() + + set(tmp_make_list) + string(REGEX REPLACE ";" "" tmp_make_list ${tmp_lib_list}) + set(${PARSE_ARGS_MAKE_LIB_LIST} "${tmp_make_list}" PARENT_SCOPE) + +endfunction(makefile_library_dirs) + # # Usage: create_exports # @@ -87,9 +181,16 @@ function (CREATE_EXPORTS) # Template file located in the CMake module directory -# Find the packages found for Amanzi +# Find the packages found for CCSE get_property(LINK_LINE GLOBAL PROPERTY CCSE_LINK_LINE) +# Define CCSE_INCLUDE_DIRS and CCSE_LIBRARY_DIRS +set(CCSE_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include") +set(CCSE_LIBRARY_DIRS "${CMAKE_INSTALL_PREFIX}/lib") + +list(REMOVE_DUPLICATES CCSE_INCLUDE_DIRS) +list(REMOVE_DUPLICATES CCSE_LIBRARY_DIRS) + # Convert the link line to a space deliminated string foreach (arg ${LINK_LINE}) set(LINK_LINE_STRING "${LINK_LINE_STRING} ${arg}") @@ -100,6 +201,10 @@ file(WRITE ${CCSE_LINK_LINE_FILE} ${LINK_LINE_STRING}) install(FILES ${CCSE_LINK_LINE_FILE} DESTINATION lib) # Write the export Makefile and add to the include install list +makefile_include_dirs(CMAKE_INCLUDE_LIST ${CCSE_INCLUDE_DIRS} + MAKE_INCLUDE_LIST CCSE_MAKE_INCLUDE_DIRS) +makefile_library_dirs(CMAKE_LIB_LIST ${CCSE_LIBRARY_DIRS} + MAKE_LIB_LIST CCSE_MAKE_LIBRARY_DIRS) set(in_makefile "${CCSE_MODULE_PATH}/MakefileConfig.export.in") set(out_makefile "${CCSE_BINARY_DIR}/Makefile.export") configure_file("${in_makefile}" "${out_makefile}")