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

Support Trilinos-based Kokkos installation. #12

Open
ambrad opened this issue Feb 6, 2019 · 2 comments
Open

Support Trilinos-based Kokkos installation. #12

ambrad opened this issue Feb 6, 2019 · 2 comments

Comments

@ambrad
Copy link
Member

ambrad commented Feb 6, 2019

No description provided.

@kuberry
Copy link
Contributor

kuberry commented Feb 6, 2019

The follow changes to CMakeLists.txt will support a shared library build of Compose, linking against Kokkos inside of Trilinos built with shared libraries. I use the CMake variable "KOKKOS_IN_TRILINOS," but obviously this can be changed to whatever you would like.

Also, this has not been tested on a static library build, or against Trilinos built as static libraries.

diff --git CMakeLists.txt CMakeLists.txt
index 2140017..7369704 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -18,7 +18,11 @@ set (COMPOSE_QLT_TIME  FALSE CACHE LOGICAL "If true, time QLT operations and dis
 
 if (Kokkos_DIR)
   include (${Kokkos_DIR}/kokkos_generated_settings.cmake)
-  set (Kokkos_INCLUDE ${Kokkos_DIR}/include)
+  if (KOKKOS_IN_TRILINOS)
+    set (Kokkos_INCLUDE ${Kokkos_DIR}/../../../include)
+  else()
+    set (Kokkos_INCLUDE ${Kokkos_DIR}/include)
+  endif()
   list2str ("${KOKKOS_CXXFLAGS}" Kokkos_CXX_FLAGS)
   list2str ("${KOKKOS_LD_FLAGS}" Kokkos_LD_FLAGS)
   string (FIND "${KOKKOS_GMAKE_DEVICES}" "Cuda" cuda_str_pos)
@@ -88,9 +92,19 @@ set (COMPOSE_COMPILE_FLAGS "-g ${Kokkos_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
 if (CUDA_BUILD)
   set (COMPOSE_COMPILE_FLAGS "${COMPOSE_COMPILE_FLAGS} --expt-relaxed-constexpr")
 endif ()
-set (COMPOSE_LINK_FLAGS "-L${Kokkos_DIR}/lib ${Kokkos_LD_FLAGS}")
+if (KOKKOS_IN_TRILINOS)
+  set (COMPOSE_LINK_FLAGS "-L${Kokkos_DIR}/../../../lib ${Kokkos_LD_FLAGS}")
+else()
+  set (COMPOSE_LINK_FLAGS "-L${Kokkos_DIR}/lib ${Kokkos_LD_FLAGS}")
+endif()
 set (COMPOSE_INCLUDES ${Kokkos_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/share ${CMAKE_BINARY_DIR}/config)
-set (COMPOSE_LIBRARIES ${KOKKOS_LIBS_LIST})
+if (KOKKOS_IN_TRILINOS)
+  set (COMPOSE_LIBRARIES "-lkokkoscore")
+  set(CMAKE_PREFIX_PATH "${Kokkos_DIR}/../../../lib" ${CMAKE_PREFIX_PATH})
+  FIND_LIBRARY(KOKKOSCORE_LIB kokkoscore)
+else()
+  set (COMPOSE_LIBRARIES ${KOKKOS_LIBS_LIST})
+endif()
 
 prc (COMPOSE_COMPILE_FLAGS)
 prc (COMPOSE_LINK_FLAGS)
@@ -101,16 +115,21 @@ prc (COMPOSE_DEBUG_MPI)
 add_definitions (-DCOMPOSE_CONFIG_IS_CMAKE)
 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/compose_config.h.in ${CMAKE_BINARY_DIR}/config/compose_config.h)
 
-add_library (${PROJECT_NAME} ${SOURCES})
+add_library (${PROJECT_NAME} SHARED ${SOURCES})
 set_target_properties (${PROJECT_NAME} PROPERTIES
   COMPILE_FLAGS "${COMPOSE_COMPILE_FLAGS}"
   LINK_FLAGS "${COMPOSE_LINK_FLAGS}")
+#  LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
 target_include_directories (${PROJECT_NAME} PUBLIC cedr siqk)
 target_include_directories (${PROJECT_NAME} PRIVATE siqk cedr)
 target_include_directories (${PROJECT_NAME} PUBLIC ${COMPOSE_INCLUDES})
-target_link_libraries (${PROJECT_NAME} ${COMPOSE_LIBRARIES})
+target_link_libraries (${PROJECT_NAME} PUBLIC ${COMPOSE_LIBRARIES})
+if (KOKKOS_IN_TRILINOS)
+    target_link_libraries(${PROJECT_NAME} PUBLIC ${KOKKOSCORE_LIB})
+endif()
 
-install (TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
+
+install (TARGETS ${PROJECT_NAME} DESTINATION lib)
 install (FILES ${HEADERS} DESTINATION include/compose)
 
 enable_testing ()

@ambrad
Copy link
Member Author

ambrad commented Feb 7, 2019

PR #19 permits installation as a shared library. Trilinos-based Kokkos support will be a separate PR.

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