Closed fcooper8472 closed 6 years ago
have a look at how I did the openmp compile and link flags using target_compile_options
and target_link_libraries
:
# OpenMP as an optional component for tests
option(Template_USE_OPENMP "Use OpenMP for shared memory parallism" OFF)
if (Template_USE_OPENMP)
find_package(OpenMP REQUIRED)
target_compile_options(mytest PRIVATE "${OpenMP_CXX_FLAGS}")
target_link_libraries(mytest PRIVATE "${OpenMP_EXE_LINKER_FLAGS}")
endif()
You will also need to filter out only the clang compiler as well
If you need these flags for both the library and test executables, best way is to add them to mylib
as PUBLIC
, then they will automatically be transferred to mytest
I have an implementation ready to go, just want your opinion @martinjrobins:
If someone runs cmake -DTemplate_MEMCHECK=ON
and they are using gcc rather than clang, would you prefer a CMake WARNING
or a CMake FATAL_ERROR
?
I think if the user specifically requests functionality it's OK to make it a FATAL_ERROR
?
I agree, make it a FATAL_ERROR. If I request a feature and it can't be satisfied, that is an error.
Happy with that changeset @martinjrobins ?
looks good. We might also want to change the way that the coverage option is handled so that it is consistent with the memcheck
Do we just want coverage on GCC, or Clang too?
well, probably want the ability to check coverage on both gcc and clang, but travis only do it for one of them.
On 9 May 2018 at 16:24, Fergus Cooper notifications@github.com wrote:
Do we just want coverage on GCC, or Clang too?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OxfordRSE/template-project-cpp/issues/8#issuecomment-387777102, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGF9LDTe_mNRnlNwYSQLoj-zXOTMrggks5twwowgaJpZM4T4Lv9 .
OK - I'll close this issue and open a new one for sorting out coverage.
This seems to be the current best practice for detecting memory errors in C++ code, and it seems very straightforward to use.
@martinjrobins what's the modern-CMake-approved method of passing
to the (clang) compiler, and
to the (clang) linker?