Skip to content

Commit

Permalink
cmake fixes due to Ben Andre
Browse files Browse the repository at this point in the history
  • Loading branch information
drummerdoc committed Dec 2, 2011
1 parent 5c9e6f2 commit 87fcbfc
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 7 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand Down
107 changes: 106 additions & 1 deletion Tools/CMake/InstallManager.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 )



Expand All @@ -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
#
Expand All @@ -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}")
Expand All @@ -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}")
Expand Down

0 comments on commit 87fcbfc

Please sign in to comment.