-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compile more examples by adding source to a list
- Loading branch information
Showing
1 changed file
with
46 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,46 @@ | ||
# | ||
# Simple Trixi Controller (C version) | ||
# | ||
add_executable(simple_trixi_controller_c simple_trixi_controller.c) | ||
|
||
target_link_libraries( | ||
simple_trixi_controller_c | ||
PRIVATE ${MPI_C_LIBRARIES} ${PROJECT_NAME} ${PROJECT_NAME}_tls | ||
) | ||
|
||
target_include_directories( | ||
simple_trixi_controller_c | ||
PRIVATE ${CMAKE_SOURCE_DIR}/src ${MPI_C_INCLUDE_DIRS} | ||
) | ||
|
||
# Set runtime path for installed binaries | ||
set_target_properties( simple_trixi_controller_c PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") | ||
|
||
install( TARGETS simple_trixi_controller_c ) | ||
|
||
|
||
|
||
# | ||
# Simple Trixi Controller (Fortran version) | ||
# | ||
add_executable(simple_trixi_controller_f simple_trixi_controller.f90) | ||
|
||
target_link_directories(simple_trixi_controller_f PRIVATE ${CMAKE_BINARY_DIR}) | ||
|
||
target_link_libraries( | ||
simple_trixi_controller_f | ||
PRIVATE ${MPI_Fortran_LIBRARIES} ${PROJECT_NAME} ${PROJECT_NAME}_tls | ||
) | ||
|
||
target_include_directories( | ||
simple_trixi_controller_f | ||
PRIVATE ${CMAKE_SOURCE_DIR}/src ${MPI_Fortran_INCLUDE_DIRS} | ||
) | ||
|
||
# Set runtime path for installed binaries | ||
set_target_properties( simple_trixi_controller_f PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") | ||
|
||
install( TARGETS simple_trixi_controller_f ) | ||
set ( EXAMPLES | ||
simple_trixi_controller.c | ||
simple_trixi_controller.f90 ) | ||
|
||
|
||
foreach ( EXAMPLE ${EXAMPLES} ) | ||
|
||
get_filename_component ( EXAMPLE_EXT ${EXAMPLE} EXT ) | ||
get_filename_component ( EXAMPLE_BASE ${EXAMPLE} NAME_WE ) | ||
|
||
if ( ${EXAMPLE_EXT} STREQUAL ".c" ) | ||
set ( EXAMPLE_LANG "C" ) | ||
set ( TARGET_EXT "c" ) | ||
elseif ( ${EXAMPLE_EXT} STREQUAL ".f90" ) | ||
set ( EXAMPLE_LANG "Fortran" ) | ||
set ( TARGET_EXT "f" ) | ||
else () | ||
message( FATAL_ERROR "Cannot handle extension " ${EXAMPLE_EXT} ) | ||
endif() | ||
|
||
# define target | ||
set ( TARGET_NAME ${EXAMPLE_BASE}_${TARGET_EXT} ) | ||
add_executable ( ${TARGET_NAME} ${EXAMPLE}) | ||
|
||
# set libraries to link | ||
target_link_libraries( | ||
${TARGET_NAME} | ||
PRIVATE ${MPI_${EXAMPLE_LANG}_LIBRARIES} ${PROJECT_NAME} ${PROJECT_NAME}_tls | ||
) | ||
|
||
# set include directories | ||
target_include_directories( | ||
${TARGET_NAME} | ||
PRIVATE ${CMAKE_SOURCE_DIR}/src ${MPI_${EXAMPLE_LANG}_INCLUDE_DIRS} | ||
) | ||
|
||
# set runtime path for installed binaries | ||
set_target_properties( | ||
${TARGET_NAME} | ||
PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" | ||
) | ||
|
||
# add to installation | ||
install( TARGETS ${TARGET_NAME} ) | ||
|
||
endforeach() |