Skip to content

Commit f706c78

Browse files
authored
More portable PIC (#966)
1 parent b22b043 commit f706c78

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ add_library(ada ada.cpp)
1111
target_compile_features(ada PUBLIC cxx_std_20)
1212
target_include_directories(ada PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> )
1313
target_include_directories(ada PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>")
14-
14+
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
15+
# We default to ON for all targets, so that we can use the library in shared libraries.
16+
set_target_properties(ada PROPERTIES POSITION_INDEPENDENT_CODE ON)
17+
endif(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
1518
if(MSVC)
1619
if("${MSVC_TOOLSET_VERSION}" STREQUAL "140")
1720
target_compile_options(ada INTERFACE /W0 /sdl)
@@ -20,9 +23,6 @@ if(MSVC)
2023
target_compile_options(ada PRIVATE /WX /W3 /sdl /w34714) # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4714?view=vs-2019
2124
endif()
2225
else(MSVC)
23-
if(NOT WIN32)
24-
target_compile_options(ada INTERFACE -fPIC)
25-
endif()
2626
message(STATUS "Assuming GCC-like compiler.")
2727
target_compile_options(ada PRIVATE -Wall -Wextra -Weffc++)
2828
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

0 commit comments

Comments
 (0)