Skip to content

Commit

Permalink
cmake: Use POSITION_INDEPENDENT_CODE target property.
Browse files Browse the repository at this point in the history
For convenience libraries, instead of mucking about with compilation
flags.

Suggested by Chad Versace on Waffle mailing list.
  • Loading branch information
jrfonseca committed Jul 17, 2014
1 parent 777194d commit d995539
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cmake/ConvenienceLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ function (add_convenience_library)

add_library ("${name}" STATIC ${ARGV})

if (NOT "${CMAKE_SHARED_LIBRARY_C_FLAGS}" STREQUAL "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
message (FATAL_ERROR "CMAKE_SHARED_LIBRARY_C_FLAGS (${CMAKE_SHARED_LIBRARY_C_FLAGS}) != CMAKE_SHARED_LIBRARY_CXX_FLAGS (${CMAKE_SHARED_LIBRARY_CXX_FLAGS})")
endif ()

set_target_properties ("${name}" PROPERTIES
# Ensure it can be statically linked in shared libraries
COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
# Ensure it can be statically linked onto shared libraries
POSITION_INDEPENDENT_CODE ON
)

endfunction ()

0 comments on commit d995539

Please sign in to comment.