diff --git a/cmake/Modules/OpmCompile.cmake b/cmake/Modules/OpmCompile.cmake index 412c535e..aeb0ef68 100644 --- a/cmake/Modules/OpmCompile.cmake +++ b/cmake/Modules/OpmCompile.cmake @@ -38,7 +38,13 @@ macro (opm_compile opm) # pre-compile common headers; this is setup *after* the library to pick # up extra options set there if (PRECOMPILE_HEADERS) - get_target_property (_type ${${opm}_TARGET} TYPE) + # if we have no library, then use the static setting as this will + # build the same way as any test programs (no -fPIC option) + if (${opm}_TARGET) + get_target_property (_type ${${opm}_TARGET} TYPE) + else () + set (_type "STATIC") + endif () precompile_header (CXX ${_type} HEADER "${${opm}_PRECOMP_CXX_HEADER}" TARGET ${opm}_CXX_pch diff --git a/cmake/Modules/OpmLibMain.cmake b/cmake/Modules/OpmLibMain.cmake index 5dcf193d..f902bc16 100644 --- a/cmake/Modules/OpmLibMain.cmake +++ b/cmake/Modules/OpmLibMain.cmake @@ -225,7 +225,9 @@ opm_doc (${project} ${doxy_dir}) # provide compatibility with using this build in dunecontrol include (DuneCompat) include (LibtoolArchives) -configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE) +if (${project}_TARGET) + configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE) +endif () ### clean in-source builds ### include (OpmDistClean) diff --git a/cmake/Modules/UseVersion.cmake b/cmake/Modules/UseVersion.cmake index 3f0d9808..b77c5aac 100644 --- a/cmake/Modules/UseVersion.cmake +++ b/cmake/Modules/UseVersion.cmake @@ -46,7 +46,9 @@ else () # the target above gets built every time thanks to the "ALL" modifier, # but it must also be done before the main library so it can pick up # any changes it does. - add_dependencies (${${project}_TARGET} update-version) + if (${project}_TARGET) + add_dependencies (${${project}_TARGET} update-version) + endif () endif () endif ()