[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[4diac-dev] Exported functionblock files and CMakeLists.txt
|
Good evening!
As I was working with the exporter a lot during the last weeks, I
stumbled across one thing over and over again: the dreaded
CMakeLists.txt.
As this is a manual step in between runtime and ide there is quite some
chance to get into trouble.
The attached file is almost a drop-in-and-forget CMakeList.txt. It takes
the directory name as a module name, and adds all .cpp and .h files for
compilation. There are still some rough edges (e.g. the description
field does not get updated when the file-list changes, automatic
regeneration of cmake-files might be problematic,...)
Now i wonder: Has anyone come up with a better solution? Is anybody
interested in such a solution? Does this break with someones setup?
Best regards,
Ernst Blecha
--
Ernst Blecha
LIT | Cyber-Physical Systems Lab
JOHANNES KEPLER
UNIVERSITY LINZ
Altenberger Straße 69
LIT Open Innovation Center
4040 Linz, Austria
ernst.blecha@xxxxxx
www.jku.at
# retrieve all cpp files, assume there is an accompanying h file
file(GLOB files LIST_DIRECTORIES false CONFIGURE_DEPENDS "*.cpp")
# loop over the files, remove extension
foreach(file ${files})
get_filename_component(name ${file} NAME_WE)
list(APPEND filenames ${name})
endforeach()
# create a newline-seperated list of files for the description
list(JOIN filenames "\n" stringfiles)
# use the current directory name as basis for naming the module
get_filename_component(name ${CMAKE_CURRENT_LIST_DIR} NAME)
# add a module (does not update the module description?)
forte_add_module("EXTERNAL_${name}" "${CMAKE_CURRENT_LIST_DIR}\n${stringfiles}")
#message(STATUS "External Module: ${name}") # debug message; output current module name
# add all the sources
foreach(file ${filenames})
forte_add_sourcefile_hcpp(${file})
# message(STATUS " ${name}") # debug message; output current filename
endforeach()