Skip to content

Commit

Permalink
BUILD: Let CMake parse the programs list from automake as well
Browse files Browse the repository at this point in the history
Instead of duplicating the list of executables to create in the CMake
file, we can just parse it from our automake files, too.
  • Loading branch information
DrMcCoy committed Feb 25, 2017
1 parent 21a431e commit edeb305
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,11 @@ endif(ICONV_SECOND_ARGUMENT_IS_CONST)
# phaethon main targets, parsed from the Automake rules.mk files
include_directories(${PROJECT_SOURCE_DIR})
add_definitions(-DPACKAGE_STRING="phaethon ${phaethon_VERSION}")

parse_automake(src/rules.mk)
target_link_libraries(phaethon ${PHAETHON_LIBRARIES})
foreach(AM_PROGRAM ${AM_PROGRAMS})
target_link_libraries(${AM_PROGRAM} ${PHAETHON_LIBRARIES})
endforeach()


# -------------------------------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion cmake/CMakeAM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ function(parse_automake AM_FILE_NAME)

include(${CMAKE_OUTPUT_FILE})

# Search for convenience libraries, creating CMake targets
set(AM_TARGETS)

# Search for convenience libraries, creating CMake targets
set(AM_STATIC_LIBRARIES)
foreach(AM_FILE ${noinst_LTLIBRARIES})
string(REPLACE "." "_" AM_NAME "${AM_FILE}")
string(REPLACE "/" "_" AM_NAME "${AM_NAME}")
Expand All @@ -150,9 +152,11 @@ function(parse_automake AM_FILE_NAME)
am_target_name(${AM_FOLDER} ${AM_FILE} AM_TARGET)
set(${AM_TARGET}_LINK_TARGETS ${${AM_TARGET}_LINK_TARGETS} PARENT_SCOPE)
list(APPEND AM_TARGETS ${AM_TARGET})
list(APPEND AM_STATIC_LIBRARIES ${AM_TARGET})
endforeach()

# Search for programs, creating CMake targets
set(AM_PROGRAMS)
foreach(AM_FILE ${bin_PROGRAMS})
string(REPLACE "." "_" AM_NAME "${AM_FILE}")
string(REPLACE "/" "_" AM_NAME "${AM_NAME}")
Expand All @@ -161,7 +165,10 @@ function(parse_automake AM_FILE_NAME)
am_target_name(${AM_FOLDER} ${AM_FILE} AM_TARGET)
set(${AM_TARGET}_LINK_TARGETS ${${AM_TARGET}_LINK_TARGETS} PARENT_SCOPE)
list(APPEND AM_TARGETS ${AM_TARGET})
list(APPEND AM_PROGRAMS ${AM_TARGET})
endforeach()

set(AM_TARGETS ${AM_TARGETS} PARENT_SCOPE)
set(AM_STATIC_LIBRARIES ${AM_STATIC_LIBRARIES} PARENT_SCOPE)
set(AM_PROGRAMS ${AM_PROGRAMS} PARENT_SCOPE)
endfunction()

0 comments on commit edeb305

Please sign in to comment.