Skip to content

Commit

Permalink
Merge pull request #80 from GEOS-ESM/feature/tclune/#58-support-varia…
Browse files Browse the repository at this point in the history
…nt-placement-of-@

Fixes #78 support for varying @ placement
  • Loading branch information
mathomp4 authored Apr 15, 2020
2 parents b1fd845 + ed9b902 commit 629dcd0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
17 changes: 5 additions & 12 deletions esma_add_library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,19 @@ macro (esma_add_library this)
set (non_stubbed)
foreach (subdir ${ARGS_SUBCOMPONENTS})

string (SUBSTRING ${subdir} 0 1 leading_character)
if (leading_character STREQUAL "@")
string (SUBSTRING ${subdir} 1 -1 mod_name) # strip leading "@"
else ()
set (mod_name ${subdir})
endif()
string(REPLACE "@" "" mod_name ${subdir})

if (NOT rename_${subdir}) # usual case
set (module_name ${mod_name})
else ()
set(module_name ${rename_${mod_name}})
endif ()

if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subdir})
add_subdirectory (${subdir})
esma_add_subdirectory(${mod_name} FOUND found)
if (found)
list (APPEND non_stubbed ${mod_name})
else () # make stub and append to sources (in ARGS_SOURCES)
if (CMAKE_DEBUG)
message (STATUS " ... Creating stub component ${module_name}")
endif()
else ()
ecbuild_debug(" ... Creating stub component ${module_name}")
esma_create_stub_component (ARGS_SOURCES ${module_name})
endif ()

Expand Down
42 changes: 35 additions & 7 deletions esma_add_subdirectories.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,41 @@
# can build in multiple configurations, and the build system must be
# able to skip non-existent directiories in the list.

macro (esma_add_subdirectories dirs)
set (dirs_ ${dirs} ${ARGN})
foreach (subdirectory ${dirs_})
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subdirectory})
add_subdirectory (${subdirectory})
endif ()
# We allow nested repositories to have leading or trailing "@" in their
# name which is disregarded for everything except path.

function (esma_add_subdirectory dir)

set (options)
set (oneValueArgs FOUND)
set (multiValueArgs)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

string(REPLACE "@" "" dir_ ${dir})

foreach(d ${dir_} "@${dir_}" "${dir}@")
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${d})
add_subdirectory (${d})
if (ARGS_FOUND)
set (${ARGS_FOUND} TRUE PARENT_SCOPE)
endif()
return()
else ()
if (ARGS_FOUND)
set (${ARGS_FOUND} FALSE PARENT_SCOPE)
else ()
ecbuild_warn(" directory not found ${dir}")
endif()
endif ()
endforeach()

endmacro (esma_add_subdirectories)
endfunction (esma_add_subdirectory)

function (esma_add_subdirectories dirs)
set (dirs_ ${dirs} ${ARGN})
ecbuild_info ("esma_add_subdirectiories: ${dirs}")
foreach (subdir ${dirs_})
esma_add_subdirectory(${subdir})
endforeach()
endfunction (esma_add_subdirectories)

6 changes: 0 additions & 6 deletions esma_add_subdirectory.cmake

This file was deleted.

9 changes: 2 additions & 7 deletions esma_set_this.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ macro (esma_set_this)
set (this ${ARGS_OVERRIDE})
else ()
get_filename_component (dir "${CMAKE_CURRENT_BINARY_DIR}" NAME)
string (SUBSTRING ${dir} 0 1 leading_character)
if (leading_character STREQUAL "@")
string (SUBSTRING ${dir} 1 -1 this) # strip leading "@"
else ()
set (this ${dir})
endif()
string(REPLACE "@" "" this ${dir})
endif ()

set(include_${this} ${esma_include}/${this})
file (MAKE_DIRECTORY ${esma_include}/${this})
file (MAKE_DIRECTORY ${esma_etc}/${this})
Expand Down

0 comments on commit 629dcd0

Please sign in to comment.