Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Build System #10

Open
jbschroder opened this issue Jul 11, 2018 · 2 comments
Open

Improve Build System #10

jbschroder opened this issue Jul 11, 2018 · 2 comments

Comments

@jbschroder
Copy link
Member

Possible build system improvements

  • Have Make create an install and lib directory
  • Have Make check for a "makefile.local" that can override makefile.inc and also specify the locations of hypre, mfem and other libraries. This file would not be in the repository, so it would make pushing and pulling easier.
@bangerth
Copy link

bangerth commented Apr 7, 2023

Might I suggest you just switch to cmake right away? CMake automates a lot of the things like building libraries and makes it platform independent. If you're interested, I could help with that. Here, for example, is a first stab at a CMakeLists.txt file:

cmake_minimum_required(VERSION 3.1)

project(BRAID)
set(BRAID_PROJECT_VERSION "3.2")

find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})


set (BRAID_HEADERS 
 braid/_braid.h
 braid/base.h
 braid/status.h
 braid/tape.h
 braid/util.h
 braid/braid.h
 braid/braid_status.h
 braid/braid_test.h)

set (BRAID_SOURCE_FILES 
 braid/access.c
 braid/adjoint.c
 braid/base.c
 braid/braid.c
 braid/braid_status.c
 braid/braid_F90_iface.c
 braid/braid_test.c
 braid/communication.c
 braid/delta.c
 braid/distribution.c
 braid/drive.c
 braid/grid.c
 braid/hierarchy.c
 braid/interp.c
 braid/mpistubs.c
 braid/norm.c
 braid/refine.c
 braid/relax.c
 braid/residual.c
 braid/restrict.c
 braid/space.c
 braid/step.c
 braid/tape.c
 braid/util.c
 braid/uvector.c)


add_library(braid SHARED
    ${BRAID_SOURCE_FILES}
)

set_target_properties(braid PROPERTIES VERSION ${BRAID_PROJECT_VERSION})
target_link_libraries(braid ${MPI_LIBRARIES})

if(MPI_COMPILE_FLAGS)
  set_target_properties(braid PROPERTIES
    COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
endif()

if(MPI_LINK_FLAGS)
  set_target_properties(braid PROPERTIES
    LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()

set_property(TARGET braid PROPERTY C_STANDARD 11)

If you place this in your top-level directory, and do

cmake .
make

then you will end up with a shared library. I haven't added the code for installation yet, nor what header files need to be exported, but it doesn't require a lot of code altogether.

@bangerth
Copy link

bangerth commented Apr 7, 2023

For reference, this is modeled on this very nice post: https://stackoverflow.com/questions/17511496/how-to-create-a-shared-library-with-cmake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants