diff --git a/CMakeLists.txt b/CMakeLists.txt index dd39c56f..1b1218b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,16 +19,13 @@ mark_as_advanced(MPI_COMPILER MPI_EXEC) include_directories (${PETSC_INCLUDES} ${IMESH_INCLUDES} ${MPI_INCLUDE_PATH}) add_definitions (${PETSC_DEFINITIONS} ${MPI_COMPILE_FLAGS}) -option (Dohp_USE_DEBUG "Compile with debugging support" ON) -option (Dohp_BUILD_TESTS "Build tests" ON) -option (Dohp_BUILD_SANDBOX "Build programs in sandbox" ON) -option (PEDANTIC_WARNINGS "Compile with pedantic warnings" ON) -option (BUILD_SHARED_LIBS "Build shared Dohp libraries" ON) +option (dUSE_DEBUG "Compile Dohp with extra debugging" ON) +option (Dohp_BUILD_TESTS "Build tests" ON) +option (Dohp_BUILD_SANDBOX "Build programs in sandbox" ON) +option (PEDANTIC_WARNINGS "Compile with pedantic warnings" ON) +option (BUILD_SHARED_LIBS "Build shared Dohp libraries" ON) -add_definitions (-std=c99) -if (Dohp_USE_DEBUG) - add_definitions (-DdUSE_DEBUG=1 -g3) -endif (Dohp_USE_DEBUG) +list (APPEND CMAKE_C_FLAGS -std=c99) if (Dohp_BUILD_TESTS) enable_testing () @@ -45,13 +42,25 @@ if (PEDANTIC_WARNINGS) add_definitions (${PEDANTIC_FLAGS}) endif (PEDANTIC_WARNINGS) +configure_file (${Dohp_SOURCE_DIR}/dohpconfig.h.in + ${Dohp_BINARY_DIR}/include/dohpconfig.h @ONLY) + add_custom_target (etags etags `find include src sandbox -name *.[ch]` WORKING_DIRECTORY ${Dohp_SOURCE_DIR}) -include_directories (${Dohp_SOURCE_DIR}/include) +include_directories (${Dohp_SOURCE_DIR}/include ${Dohp_BINARY_DIR}/include) + +set (Dohp_DEPENDENT_LIBRARIES ${IMESH_LIBRARIES} ${PETSC_LIBRARIES} ${MPI_LIBRARIES}) +set (Dohp_LIBRARIES dohp ${Dohp_DEPENDENT_LIBRARIES}) + +set (ARCHIVE_OUTPUT_DIRECTORY ${Dohp_BINARY_DIR}/lib CACHE PATH "Output directory for Dohp archives") +set (LIBRARY_OUTPUT_DIRECTORY ${Dohp_BINARY_DIR}/lib CACHE PATH "Output directory for Dohp libraries") +set (RUNTIME_OUTPUT_DIRECTORY ${Dohp_BINARY_DIR}/bin CACHE PATH "Output directory for Dohp executables") +mark_as_advanced (ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY) -set (Dohp_LIBRARIES dohp ${IMESH_LIBRARIES} ${PETSC_LIBRARIES} ${MPI_LIBRARIES}) +set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) add_subdirectory (include) add_subdirectory (src) diff --git a/dohpconfig.h.in b/dohpconfig.h.in new file mode 100644 index 00000000..1f17aa1b --- /dev/null +++ b/dohpconfig.h.in @@ -0,0 +1,6 @@ +#ifndef _DOHPCONFIG_H +#define _DOHPCONFIG_H + +#cmakedefine dUSE_DEBUG + +#endif diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 3f49a088..48aad244 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,4 +1,11 @@ -INSTALL_FILES (/include FILES - dohp.h dohpfs.h dohpgeom.h dohpjacobi.h dohpmesh.h dohpquotient.h dohptype.h) +install_files (/include FILES + dohpconfig.h + dohp.h + dohpfs.h + dohpgeom.h + dohpjacobi.h + dohpmesh.h + dohpquotient.h + dohptype.h) # Do not include the headers in private, they're private. diff --git a/include/dohptype.h b/include/dohptype.h index 62cad7a3..cc21b613 100644 --- a/include/dohptype.h +++ b/include/dohptype.h @@ -1,6 +1,7 @@ #ifndef _DOHPTYPE_H #define _DOHPTYPE_H +#include "dohpconfig.h" #include "petsc.h" #include "iMesh.h" @@ -130,8 +131,7 @@ static inline dScalar dColonSymScalar3(const dScalar a[6],const dScalar b[6]) #define dNAME_LEN 256 #define dSTR_LEN 256 -/* defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) */ -#if 1 +#if defined(__GNUC__) # define dUNUSED __attribute__((unused)) # define dLIKELY(x) __builtin_expect(!!(x),1) # define dUNLIKELY(x) __builtin_expect(!!(x),0) diff --git a/sandbox/itaps/CMakeLists.txt b/sandbox/itaps/CMakeLists.txt index 7f4ea397..32fad68e 100644 --- a/sandbox/itaps/CMakeLists.txt +++ b/sandbox/itaps/CMakeLists.txt @@ -5,5 +5,9 @@ set (Dohp_SANDBOX_EXECS foreach (EXE ${Dohp_SANDBOX_EXECS}) add_executable (${EXE} "${EXE}.c") - target_link_libraries (${EXE} ${Dohp_LIBRARIES}) + #target_link_libraries (${EXE} ${Dohp_LIBRARIES}) + target_link_libraries (${EXE} dohp) endforeach (EXE) + +install (TARGETS ${Dohp_SANDBOX_EXECS} + RUNTIME DESTINATION bin) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8ff6036..05f41cf4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,20 +14,24 @@ list (APPEND Dohp_SRCS jacobi/impls/tensor/efstopo.c) # ADD_SUBDIRECTORY (fs) -LIST (APPEND Dohp_SRCS +list (APPEND Dohp_SRCS fs/interface/fs.c fs/interface/fsreg.c fs/interface/q1.c fs/impls/cont/cont.c) # ADD_SUBDIRECTORY (fs/mesh) -LIST (APPEND Dohp_SRCS +list (APPEND Dohp_SRCS fs/mesh/interface/mesh.c fs/mesh/interface/meshreg.c fs/mesh/impls/pack/pack.c fs/mesh/impls/serial/serial.c) -ADD_LIBRARY (dohp ${Dohp_SRCS}) +add_library (dohp ${Dohp_SRCS}) +target_link_libraries (dohp ${Dohp_DEPENDENT_LIBRARIES}) +install (TARGETS dohp + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) if (Dohp_BUILD_TESTS) add_subdirectory (fs/tests) diff --git a/src/fs/tests/CMakeLists.txt b/src/fs/tests/CMakeLists.txt index 81ecc8e3..26cabb2c 100644 --- a/src/fs/tests/CMakeLists.txt +++ b/src/fs/tests/CMakeLists.txt @@ -1,14 +1,17 @@ -add_executable (ex1 ex1.c) -target_link_libraries(ex1 ${Dohp_LIBRARIES}) -add_executable (ex2 ex2.c) -target_link_libraries(ex2 ${Dohp_LIBRARIES}) -add_executable (ex3 ex3.c) -target_link_libraries(ex3 ${Dohp_LIBRARIES}) -add_executable (ellip ellip.c) -target_link_libraries(ellip ${Dohp_LIBRARIES}) +macro (dohp_link_executable name source) + add_executable (${name} ${source}) + target_link_libraries (${name} dohp) +endmacro () -add_test (fs-mf-projection ex1 -snes_mf -ksp_type minres -const_BDeg 6 -snes_monitor -ksp_converged_reason) -add_test (fs-mf-op-proj-0 ex1 -snes_mf_operator -ksp_type minres -pc_type jacobi -const_BDeg 10 -snes_monitor -ksp_converged_reason +dohp_link_executable (fs-ex1 ex1.c) +dohp_link_executable (ellip ellip.c) +# add_executable (ex2 ex2.c) +# target_link_libraries(ex2 ${Dohp_LIBRARIES}) +# add_executable (ex3 ex3.c) +#target_link_libraries(ex3 ${Dohp_LIBRARIES}) + +add_test (fs-mf-projection fs-ex1 -snes_mf -ksp_type minres -const_BDeg 6 -snes_monitor -ksp_converged_reason) +add_test (fs-mf-op-proj-0 fs-ex1 -snes_mf_operator -ksp_type minres -pc_type jacobi -const_BDeg 10 -snes_monitor -ksp_converged_reason -ksp_rtol 1e-10 -q1scale 0.5 -frequency 5,4,3 -require_ptwise 2e-6,3e-6,2.3e-5 -require_grad 7e-7,3e-6,2e-4) -add_test (fs-mf-op-proj-1 ex1 -const_BDeg 7 -snes_mf_operator -ksp_converged_reason -pc_type jacobi -ksp_type minres +add_test (fs-mf-op-proj-1 fs-ex1 -const_BDeg 7 -snes_mf_operator -ksp_converged_reason -pc_type jacobi -ksp_type minres -ksp_rtol 1e-10 -snes_monitor -frequency 2,2,2 -require_ptwise 2e-6,2e-6,9e-6 -require_grad 3e-6,7e-6,1.1e-4)