diff --git a/.github/workflows/ci-cmake-options.yml b/.github/workflows/ci-cmake-options.yml index abcc6703..46c93a96 100644 --- a/.github/workflows/ci-cmake-options.yml +++ b/.github/workflows/ci-cmake-options.yml @@ -32,7 +32,7 @@ jobs: cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build cd ${{ github.workspace }}/build export VERBOSE=1 - make install -j$(nproc) + make install -j$(nproc) - name: CMake Release install run: | @@ -41,7 +41,7 @@ jobs: cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=Release cd ${{ github.workspace }}/build export VERBOSE=1 - make install -j$(nproc) + make install -j$(nproc) - name: CMake Debug install run: | @@ -50,7 +50,7 @@ jobs: cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=Debug cd ${{ github.workspace }}/build export VERBOSE=1 - make install -j$(nproc) + make install -j$(nproc) - name: CMake RelWithDebInfo install run: | @@ -59,7 +59,7 @@ jobs: cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=RelWithDebInfo cd ${{ github.workspace }}/build export VERBOSE=1 - make install -j$(nproc) + make install -j$(nproc) - name: CMake Custom build install run: | @@ -83,7 +83,7 @@ jobs: run: | cmake --version rm -rf ${{ github.workspace }}/build - cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build -DCMAKE_CXX_FLAGS="-O2 -g -fPIC" + cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build -DCMAKE_CXX_FLAGS="-O2 -g" cd ${{ github.workspace }}/build export VERBOSE=1 make install -j$(nproc) @@ -95,7 +95,7 @@ jobs: export CXXFLAGS="-grecord-gcc-switches" export CFLAGS="-fstack-protector-strong" export LDFLAGS="-Wl,-z,now" - cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build -DCMAKE_CXX_FLAGS_CUSTOM:STRING="-O2 -g -fPIC" -DCMAKE_BUILD_TYPE=CUSTOM + cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build -DCMAKE_CXX_FLAGS_CUSTOM:STRING="-O2 -g" -DCMAKE_BUILD_TYPE=CUSTOM cd ${{ github.workspace }}/build export VERBOSE=1 make install -j$(nproc) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1630bc81..e3de93a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(PCM) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) option(PCM_NO_ASAN "Disable address sanitizer" OFF) @@ -64,7 +64,7 @@ if(UNIX) # APPLE, LINUX, FREE_BSD message(STATUS "initial CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") # required PCM common flags - set (PCM_COMMON_FLAGS "-Wno-unknown-pragmas -fPIC -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"") + set (PCM_COMMON_FLAGS "-Wno-unknown-pragmas -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"") if(LINUX) set (PCM_COMMON_FLAGS "${PCM_COMMON_FLAGS} -Wextra -DPCM_USE_PERF") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e0b7fe2..b0b22152 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,7 +56,7 @@ if(UNIX) # LINUX, FREE_BSD, APPLE $<$:PCM_SILENT> ) - target_compile_options(PCM_STATIC_SILENT PRIVATE "-fPIC") + set_target_properties(PCM_STATIC_SILENT PROPERTIES POSITION_INDEPENDENT_CODE ON) # libpcm.so add_library(PCM_SHARED SHARED pcm-core.cpp)