Skip to content

Commit

Permalink
Rework compiler & linker options
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed May 20, 2024
1 parent 680cf22 commit 2c6384a
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,16 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

if(NOT CMAKE_C_FLAGS MATCHES "-fPIC")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fPIC")
endif()

if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-variable")
endif()

if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-variable")
endif()

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
link_libraries(Threads::Threads)
add_compile_options(
"-Wall"
"-Wextra"
"-Wno-unused-variable"
"-fPIC"
"-pthread"
)

# for libroc.a
link_libraries(
"stdc++"
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -pthread -lstdc++"
)

add_definitions(
Expand Down

0 comments on commit 2c6384a

Please sign in to comment.