-
-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: Separate library configs in a different cmake
- Loading branch information
Showing
5 changed files
with
198 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Define and setup CanaryLib main library target | ||
add_library(${PROJECT_NAME}_lib "") | ||
setup_target(${PROJECT_NAME}_lib) | ||
|
||
# Include sources cmake file to add source files to lib | ||
include(Sources) | ||
|
||
# Add public pre compiler header to lib, to pass down to related targets | ||
target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp) | ||
|
||
# ***************************************************************************** | ||
# Build flags - need to be set before the links and sources | ||
# ***************************************************************************** | ||
if (CMAKE_COMPILER_IS_GNUCXX) | ||
target_compile_options(${PROJECT_NAME}_lib PRIVATE -Wno-deprecated-declarations) | ||
endif() | ||
|
||
# === IPO === | ||
check_ipo_supported(RESULT result OUTPUT output) | ||
if(result) | ||
set_property(TARGET ${PROJECT_NAME}_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) | ||
else() | ||
message(WARNING "IPO is not supported: ${output}") | ||
endif() | ||
|
||
# === UNITY BUILD (compile time reducer) === | ||
if(SPEED_UP_BUILD_UNITY) | ||
set_target_properties(${PROJECT_NAME}_lib PROPERTIES UNITY_BUILD ON) | ||
log_option_enabled("Build unity for speed up compilation") | ||
endif() | ||
|
||
# ***************************************************************************** | ||
# Target include directories - to allow #include | ||
# ***************************************************************************** | ||
target_include_directories(${PROJECT_NAME}_lib | ||
PUBLIC | ||
${BOOST_DI_INCLUDE_DIRS} | ||
${CMAKE_SOURCE_DIR}/src | ||
${GMP_INCLUDE_DIRS} | ||
${LUAJIT_INCLUDE_DIRS} | ||
${PARALLEL_HASHMAP_INCLUDE_DIRS} | ||
) | ||
|
||
# ***************************************************************************** | ||
# Target links to external dependencies | ||
# ***************************************************************************** | ||
target_link_libraries(${PROJECT_NAME}_lib | ||
PUBLIC | ||
${GMP_LIBRARIES} | ||
${LUAJIT_LIBRARIES} | ||
CURL::libcurl | ||
ZLIB::ZLIB | ||
absl::any absl::log absl::base absl::bits | ||
asio::asio | ||
eventpp::eventpp | ||
fmt::fmt | ||
magic_enum::magic_enum | ||
mio::mio | ||
protobuf::libprotobuf | ||
pugixml::pugixml | ||
spdlog::spdlog | ||
unofficial::argon2::libargon2 | ||
unofficial::libmariadb | ||
unofficial::mariadbclient | ||
) | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${ZLIB_LIBRARY_DEBUG}) | ||
else() | ||
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${ZLIB_LIBRARY_RELEASE}) | ||
endif() | ||
|
||
if (MSVC) | ||
if(BUILD_STATIC_LIBRARY) | ||
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_static) | ||
else() | ||
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_lib) | ||
endif() | ||
|
||
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${MYSQL_CLIENT_LIBS}) | ||
else() | ||
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_static Threads::Threads) | ||
endif (MSVC) | ||
|
||
# === OpenMP === | ||
if(OPTIONS_ENABLE_OPENMP) | ||
log_option_enabled("openmp") | ||
find_package(OpenMP) | ||
if(OpenMP_CXX_FOUND) | ||
target_link_libraries(${PROJECT_NAME}_lib PUBLIC OpenMP::OpenMP_CXX) | ||
endif() | ||
else() | ||
log_option_disabled("openmp") | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.