Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface library to btwxt #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions cmake/compiler-flags.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (UNIX)
add_definitions("-fPIC")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
endif()
add_library(btwxt_interface_library INTERFACE)

target_compile_options(btwxt_interface_library INTERFACE
$<$<CXX_COMPILER_ID:MSVC>: # Visual C++ (VS 2013)
/W4 # Warning level (default is W3)
#/WX # Turn warnings into errors
>

$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>: # GCC and Clang
-Wall # Turn on all warnings
-Wextra # Turn on extra warnings
-Wpedantic # Turn on warning not covered in Wall and Wextra
#-Werror # Turn warnings into errors
-fpic # Position Independent Code
>
)

7 changes: 1 addition & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ else()
add_library(${PROJECT_NAME} SHARED ${library_sources})
endif()

target_compile_options(btwxt PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wpedantic>
)

target_link_libraries(${PROJECT_NAME} PRIVATE btwxt_interface_library)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME})
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(library_sources

add_executable(${PROJECT_NAME}_tests ${library_sources})

target_link_libraries(${PROJECT_NAME}_tests ${PROJECT_NAME} gtest gmock)
target_link_libraries(${PROJECT_NAME}_tests PRIVATE ${PROJECT_NAME} gtest gmock btwxt_interface_library)

include(GoogleTest)

Expand Down