-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add BUILD_EXE as cmake option #717
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
59d2ed4
adding build_exe option to cmake
bam241 eb698b4
this should be ok
bam241 94d4d71
now on top of the last version of Develop...
bam241 c1f317e
adding news
bam241 dbf0209
BUILD_EXEC -> BUILD_EXE
bam241 030faf6
add header to static install
bam241 fa6c50d
udating news
bam241 0e89529
Apply suggestions from code review
bam241 cd5eeb8
alignement
bam241 39d28d1
that should be better without typo
bam241 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -66,6 +66,7 @@ macro (dagmc_setup_options) | |
option(BUILD_SHARED_LIBS "Build shared libraries" ON) | ||
option(BUILD_STATIC_LIBS "Build static libraries" ON) | ||
|
||
option(BUILD_EXE "Build DAGMC executables" ON) | ||
option(BUILD_STATIC_EXE "Build static executables" OFF) | ||
option(BUILD_PIC "Build with PIC" OFF) | ||
|
||
|
@@ -96,12 +97,14 @@ endif() | |
if (NOT BUILD_STATIC_LIBS AND BUILD_STATIC_EXE) | ||
message(FATAL_ERROR "BUILD_STATIC_EXE cannot be ON while BUILD_STATIC_LIBS is OFF") | ||
endif () | ||
if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_EXE) | ||
message(FATAL_ERROR "BUILD_STATIC_EXE cannot be OFF while BUILD_SHARED_LIBS is OFF") | ||
endif () | ||
if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) | ||
message(FATAL_ERROR "BUILD_SHARED_LIBS and BUILD_STATIC_LIBS cannot both be OFF") | ||
endif () | ||
if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_EXE AND BUILD_EXE) | ||
SET(BUILD_EXE OFF) | ||
message("Turning BUILD_EXE to OFF: SHARED_BUIL_LIBS and BUILD_STATIC_EXE are OFF") | ||
bam241 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
endif () | ||
|
||
endmacro () | ||
|
||
macro (dagmc_setup_flags) | ||
|
@@ -128,21 +131,23 @@ macro (dagmc_setup_flags) | |
set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "") | ||
set(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "") | ||
|
||
if (BUILD_STATIC_EXE) | ||
message(STATUS "Building static executables") | ||
set(BUILD_SHARED_EXE OFF) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") | ||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) | ||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) | ||
set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS) | ||
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) | ||
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS) | ||
set(CMAKE_EXE_LINK_DYNAMIC_Fortran_FLAGS) | ||
else () | ||
message(STATUS "Building shared executables") | ||
set(BUILD_SHARED_EXE ON) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) | ||
if (BUILD_EXE) | ||
if (BUILD_STATIC_EXE) | ||
message(STATUS "Building static executables") | ||
set(BUILD_SHARED_EXE OFF) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") | ||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) | ||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) | ||
set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS) | ||
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) | ||
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS) | ||
set(CMAKE_EXE_LINK_DYNAMIC_Fortran_FLAGS) | ||
else () | ||
message(STATUS "Building shared executables") | ||
set(BUILD_SHARED_EXE ON) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) | ||
endif () | ||
endif () | ||
|
||
if (BUILD_RPATH) | ||
|
@@ -259,64 +264,72 @@ endmacro () | |
|
||
# Install an executable | ||
macro (dagmc_install_exe exe_name) | ||
message(STATUS "Building executable: ${exe_name}") | ||
if (NOT BUILD_EXE) | ||
message(STATUS "Skipping executable ${exe_name} build") | ||
else () | ||
message(STATUS "Building executable: ${exe_name}") | ||
|
||
dagmc_get_link_libs() | ||
dagmc_get_link_libs() | ||
|
||
add_executable(${exe_name} ${SRC_FILES}) | ||
if (BUILD_RPATH) | ||
if (BUILD_STATIC_EXE) | ||
set_target_properties(${exe_name} | ||
PROPERTIES INSTALL_RPATH "" | ||
INSTALL_RPATH_USE_LINK_PATH FALSE) | ||
target_link_libraries(${exe_name} ${LINK_LIBS_STATIC}) | ||
else () | ||
set_target_properties(${exe_name} | ||
PROPERTIES INSTALL_RPATH "${INSTALL_RPATH_DIRS}" | ||
INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
target_link_libraries(${exe_name} PUBLIC ${LINK_LIBS_SHARED}) | ||
endif () | ||
else () | ||
if (BUILD_STATIC_EXE) | ||
target_link_libraries(${exe_name} ${LINK_LIBS_STATIC}) | ||
add_executable(${exe_name} ${SRC_FILES}) | ||
if (BUILD_RPATH) | ||
if (BUILD_STATIC_EXE) | ||
set_target_properties(${exe_name} | ||
PROPERTIES INSTALL_RPATH "" | ||
INSTALL_RPATH_USE_LINK_PATH FALSE) | ||
target_link_libraries(${exe_name} ${LINK_LIBS_STATIC}) | ||
else () | ||
set_target_properties(${exe_name} | ||
PROPERTIES INSTALL_RPATH "${INSTALL_RPATH_DIRS}" | ||
INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
target_link_libraries(${exe_name} PUBLIC ${LINK_LIBS_SHARED}) | ||
endif () | ||
else () | ||
target_link_libraries(${exe_name} PUBLIC ${LINK_LIBS_SHARED}) | ||
if (BUILD_STATIC_EXE) | ||
target_link_libraries(${exe_name} ${LINK_LIBS_STATIC}) | ||
else () | ||
target_link_libraries(${exe_name} PUBLIC ${LINK_LIBS_SHARED}) | ||
endif () | ||
endif () | ||
install(TARGETS ${exe_name} DESTINATION ${INSTALL_BIN_DIR}) | ||
endif () | ||
install(TARGETS ${exe_name} DESTINATION ${INSTALL_BIN_DIR}) | ||
endmacro () | ||
|
||
# Install a unit test | ||
macro (dagmc_install_test test_name ext) | ||
message(STATUS "Building unit tests: ${test_name}") | ||
if (NOT BUILD_EXEC) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
message(STATUS "Skipping unit tests ${test_name} build.") | ||
else () | ||
message(STATUS "Building unit tests: ${test_name}") | ||
|
||
list(APPEND LINK_LIBS gtest) | ||
list(APPEND LINK_LIBS gtest) | ||
|
||
dagmc_get_link_libs() | ||
dagmc_get_link_libs() | ||
|
||
add_executable(${test_name} ${test_name}.${ext} ${DRIVERS}) | ||
if (BUILD_RPATH) | ||
if (BUILD_STATIC_EXE) | ||
set_target_properties(${test_name} | ||
PROPERTIES INSTALL_RPATH "" | ||
INSTALL_RPATH_USE_LINK_PATH FALSE) | ||
target_link_libraries(${test_name} ${LINK_LIBS_STATIC}) | ||
else () | ||
set_target_properties(${test_name} | ||
PROPERTIES INSTALL_RPATH "${INSTALL_RPATH_DIRS}" | ||
INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
target_link_libraries(${test_name} ${LINK_LIBS_SHARED}) | ||
endif () | ||
else () | ||
if (BUILD_STATIC_EXE) | ||
target_link_libraries(${test_name} ${LINK_LIBS_STATIC}) | ||
add_executable(${test_name} ${test_name}.${ext} ${DRIVERS}) | ||
if (BUILD_RPATH) | ||
if (BUILD_STATIC_EXE) | ||
set_target_properties(${test_name} | ||
PROPERTIES INSTALL_RPATH "" | ||
INSTALL_RPATH_USE_LINK_PATH FALSE) | ||
target_link_libraries(${test_name} ${LINK_LIBS_STATIC}) | ||
else () | ||
set_target_properties(${test_name} | ||
PROPERTIES INSTALL_RPATH "${INSTALL_RPATH_DIRS}" | ||
INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
target_link_libraries(${test_name} ${LINK_LIBS_SHARED}) | ||
endif () | ||
else () | ||
target_link_libraries(${test_name} ${LINK_LIBS_SHARED}) | ||
if (BUILD_STATIC_EXE) | ||
target_link_libraries(${test_name} ${LINK_LIBS_STATIC}) | ||
else () | ||
target_link_libraries(${test_name} ${LINK_LIBS_SHARED}) | ||
endif () | ||
endif () | ||
endif () | ||
install(TARGETS ${test_name} DESTINATION ${INSTALL_TESTS_DIR}) | ||
add_test(NAME ${test_name} COMMAND ${test_name}) | ||
set_property(TEST ${test_name} PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=''") | ||
install(TARGETS ${test_name} DESTINATION ${INSTALL_TESTS_DIR}) | ||
add_test(NAME ${test_name} COMMAND ${test_name}) | ||
set_property(TEST ${test_name} PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=''") | ||
endif () | ||
endmacro () | ||
|
||
# Install a file needed for unit testing | ||
|
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
**Added:** | ||
- adding BUILD_EXE option (default ON) alowing to build only the dagmc libs | ||
without the executable (for static and/or shared libs) | ||
|
||
**Changed:** None | ||
|
||
**Deprecated:** None | ||
|
||
**Removed:** None | ||
|
||
**Fixed:** None | ||
|
||
**Security:** None |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's indent the comment string to match the other options.