Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions sparta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@ endif ()
string (STRIP ${GIT_REPO_VERSION} GIT_REPO_VERSION)
message (STATUS "Sparta Version: ${GIT_REPO_VERSION}")

#pkg-config support
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/sparta.pc.in
${CMAKE_CURRENT_BINARY_DIR}/sparta.pc
@ONLY
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/sparta.pc
DESTINATION lib/pkgconfig
)


# Use ccache if we've got it.
find_program (CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
Expand Down
11 changes: 11 additions & 0 deletions sparta/cmake/sparta.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: sparta
Description: High-performance C++ modeling framework
Version: @GIT_REPO_VERSION@
Requires: yaml-cpp sqlite3 hdf5
Libs: -L${libdir} -lsparta -lboost_program_options -lboost_filesystem -lboost_system -lboost_timer -lboost_serialization -lz
Cflags: -I${includedir} -std=c++17

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern I have with this strategy is that now I have 3 places to update if sparta changes dependencies: this file, the Sparta-config.cmake, and the README.md. They will get out of sync (if not already).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do see the maintenance overhead here, hence I am trying to make the autogeneration work - that will reduce the work to just the CMakeLists.txt - but that has required some changes. Currently the autogeneration is not working completely as the cflags extraction is either broken or I am not doing it correctly

Here is the autogeneartion that I have managed to achieve :

# sparta library pkg-config file
# Automatically generated by CMAKE

prefix=/usr/local
exec_prefix="${prefix}"
libdir="${prefix}/lib"
includedir="${prefix}/include"

Name: sparta
Description: High-performance C++ modeling framework
URL:
Version:
Cflags: -I${includedir} -DCOMPILE_DEFS-NOTFOUND
Libs: -L${libdir} -lsparta -lyaml-cpp -lz -lpthread -lboost_date_time -lboost_iostreams -lboost_serialization -lboost_timer -lboost_program_options -lsqlite3 -lhdf5

I am trying to make the cflags to work - but the current limitation of the cmake suggested by @bdutro-mips is that it only reads :

get_target_property(COMPILE_DEFS ${TARGET} INTERFACE_COMPILE_DEFINITIONS)

for generating the cflags, but flags we need :

-std=c++17 → INTERFACE_COMPILE_OPTIONS (set via target_compile_options)
-I${includedir} → INTERFACE_INCLUDE_DIRECTORIES (set via target_include_directories)
-I/usr/include/... → INTERFACE_INCLUDE_DIRECTORIES (set via target_include_directories)

So I am thinking of forking the autogeneartion script and making some changes to it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again your concern about the maintenance is very valid as I have seen it get out of sync in the pegasus repo, maybe we drop this right now and work upon this in the future. Maybe in the future we could work on

  • using the Meson build systen - that has automatic pkg-config generation -
  • or even start with a ./configure file that configures and writes everything from updating the readme to running the build.

I would like to see this feature in sparta to make the cmake more beginner friendly and easily integrate able to projects. But I need some time to figure out a better approach - towards making it as we have discussed.

Loading