Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
32fb9d51
Commit
32fb9d51
authored
May 12, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cmake update to support both header-only and static
parent
ce637440
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
18 deletions
+24
-18
CMakeLists.txt
CMakeLists.txt
+24
-18
No files found.
CMakeLists.txt
View file @
32fb9d51
...
...
@@ -45,7 +45,6 @@ else()
set
(
SPDLOG_MASTER_PROJECT OFF
)
endif
()
option
(
SPDLOG_STATIC_LIB
"Build as static lib"
ON
)
option
(
SPDLOG_BUILD_EXAMPLES
"Build examples"
${
SPDLOG_MASTER_PROJECT
}
)
option
(
SPDLOG_BUILD_BENCH
"Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)"
OFF
)
option
(
SPDLOG_BUILD_TESTS
"Build tests"
ON
)
...
...
@@ -55,29 +54,38 @@ option(SPDLOG_INSTALL "Generate the install target." ${SPDLOG_MASTER_PROJECT})
set
(
HEADER_BASE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/spdlog"
)
message
(
STATUS
"Build type: "
${
CMAKE_BUILD_TYPE
}
)
message
(
STATUS
"Static lib: "
${
SPDLOG_STATIC_LIB
}
)
if
(
SPDLOG_STATIC_LIB
)
add_definitions
(
-DSPDLOG_STATIC_LIB
)
set
(
SRC_BASE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src"
)
set
(
SRC_FILES
"
${
SRC_BASE
}
/spdlog.cpp"
)
add_library
(
spdlog STATIC
${
SRC_FILES
}
)
target_include_directories
(
spdlog PUBLIC
"$<BUILD_INTERFACE:
${
CMAKE_CURRENT_LIST_DIR
}
/include>
"
)
target_link_libraries
(
spdlog
)
# Build static lib
set
(
SRC_BASE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src"
)
set
(
STATIC_SRC_FILES
"
${
SRC_BASE
}
/spdlog.cpp"
)
add_library
(
spdlog_static STATIC
${
STATIC_SRC_FILES
}
)
add_library
(
spdlog::static ALIAS spdlog_static
)
if
(
CMAKE_BUILD_TYPE EQUAL
"RELEASE
"
)
set_target_properties
(
spdlog_static PROPERTIES OUTPUT_NAME
"spdlog"
)
else
()
add_library
(
spdlog INTERFACE
)
target_include_directories
(
spdlog INTERFACE
"$<BUILD_INTERFACE:
${
CMAKE_CURRENT_LIST_DIR
}
/include>"
)
set_target_properties
(
spdlog_static PROPERTIES OUTPUT_NAME
"spdlog-debug"
)
endif
()
add_library
(
spdlog::spdlog ALIAS spdlog
)
target_compile_definitions
(
spdlog_static PUBLIC SPDLOG_STATIC_LIB
)
target_include_directories
(
spdlog_static PUBLIC
"$<BUILD_INTERFACE:
${
CMAKE_CURRENT_LIST_DIR
}
/include>"
)
# headr only
add_library
(
spdlog_header_only INTERFACE
)
target_include_directories
(
spdlog_header_only INTERFACE
"$<BUILD_INTERFACE:
${
CMAKE_CURRENT_LIST_DIR
}
/include>"
)
add_library
(
spdlog::spdlog ALIAS spdlog_header_only
)
if
(
SPDLOG_FMT_EXTERNAL AND NOT TARGET fmt::fmt
)
find_package
(
fmt REQUIRED CONFIG
)
endif
()
if
(
SPDLOG_FMT_EXTERNAL
)
target_compile_definitions
(
spdlog INTERFACE SPDLOG_FMT_EXTERNAL
)
target_link_libraries
(
spdlog INTERFACE fmt::fmt
)
target_compile_definitions
(
spdlog_static INTERFACE SPDLOG_FMT_EXTERNAL
)
target_link_libraries
(
spdlog_static INTERFACE fmt::fmt
)
target_compile_definitions
(
spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL
)
target_link_libraries
(
spdlog_header_only INTERFACE fmt::fmt
)
endif
()
if
(
SPDLOG_BUILD_EXAMPLES
)
...
...
@@ -97,10 +105,8 @@ endif()
# install
#---------------------------------------------------------------------------------------
install
(
DIRECTORY
${
HEADER_BASE
}
DESTINATION include
)
install
(
TARGETS spdlog_static ARCHIVE DESTINATION lib
)
if
(
SPDLOG_STATIC_LIB
)
install
(
TARGETS spdlog ARCHIVE DESTINATION lib
)
endif
()
#---------------------------------------------------------------------------------------
# register project in CMake user registry
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment