CMake/Tests/RunCMake/CMP0065/BuildTargetInSubProject.cmake
Chuck Atkins 9784af1b50 CMP0065: Restrict the use of CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS
This new policy restricts the addition of the shared library link flags
to executables only when the ENABLE_EXPORTS property is set to True.
2015-09-21 10:12:13 -04:00

16 lines
624 B
CMake

function(BuildTargetInSubProject P T E)
try_compile(RESULTVAR
${CMAKE_CURRENT_BINARY_DIR}/subproject
${CMAKE_CURRENT_SOURCE_DIR}/subproject
${P} ${T} OUTPUT_VARIABLE O)
if(E AND RESULTVAR)
message(STATUS "${P} target ${T} succeeded as expected")
elseif(E AND NOT RESULTVAR)
message(FATAL_ERROR "${P} target ${T} failed but should have succeeded. Output:${O}")
elseif(NOT E AND NOT RESULTVAR)
message(STATUS "${P} target ${T} failed as expected")
elseif(NOT E AND RESULTVAR)
message(FATAL_ERROR "${P} target ${T} succeeded but should have failed. Output:${O}")
endif()
endfunction()