Skip to content

Commit bdb526e

Browse files
committed
Adding prefix to the options in cmake and removing global include directories
1 parent d20f5a7 commit bdb526e

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser")
44

55
# -- PROJECT OPTIONS -- #
66
option(DEBUG "use debug flag" NO)
7-
option(ENABLE_TESTS "Enable Unittests" ON)
7+
option(DBC_ENABLE_TESTS "Enable Unittests" ON)
88
# Turn OFF, if you are using FetchContent to include it to your project
9-
option(FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF)
10-
option(GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF)
9+
option(DBC_FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF)
10+
option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF)
1111
# ---------------------- #
1212

1313
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -68,27 +68,26 @@ set(HEADER_FILES
6868
${PROJECT_SOURCE_DIR}/include/libdbc/exceptions/error.hpp
6969
)
7070

71-
include_directories(src)
72-
include_directories(include)
73-
74-
if(ENABLE_TESTS)
71+
if(DBC_ENABLE_TESTS)
7572
include(CTest)
7673
add_subdirectory(test)
7774
endif()
7875

79-
if(GENERATE_DOCS)
76+
if(DBC_GENERATE_DOCS)
8077
add_subdirectory(doc)
8178
endif()
8279

8380
add_library(${PROJECT_NAME} STATIC ${SOURCE})
8481
target_link_libraries(${PROJECT_NAME} FastFloat::fast_float)
82+
target_include_directories(${PROJECT_NAME} PUBLIC
83+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
84+
$<INSTALL_INTERFACE:include>
85+
)
8586

86-
if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23)
87-
target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS
88-
TYPE HEADERS
89-
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
90-
FILES ${HEADER_FILES})
91-
endif()
87+
target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS
88+
TYPE HEADERS
89+
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
90+
FILES ${HEADER_FILES})
9291

9392
add_custom_target(release
9493
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -107,12 +106,12 @@ if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23 AND NOT FETCH_CONTENT_INCLUSION)
107106
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lib${PROJECT_NAME}
108107
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
109108
)
110-
elseif(NOT FETCH_CONTENT_INCLUSION)
109+
elseif(NOT DBC_FETCH_CONTENT_INCLUSION)
111110
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
112111
endif()
113112

114113

115-
if (NOT FETCH_CONTENT_INCLUSION)
114+
if (NOT DBC_FETCH_CONTENT_INCLUSION)
116115
# Generate pkg-config file
117116
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
118117
install(

0 commit comments

Comments
 (0)