From 42c9233ad945fc308ad7c93e33e73251d745e3f4 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Mon, 2 Jan 2017 17:41:39 -0500 Subject: [PATCH] compile and link third-party amalgamation as a static lib instead of object files and fix clang warnings in cryptopp --- source/CMakeLists.txt | 5 +++-- tests/CMakeLists.txt | 3 ++- third-party/CMakeLists.txt | 11 ++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a40421a2..139a5419 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -116,7 +116,7 @@ set(XLNT_SOURCES ${CELL_SOURCES} ${CHARTS_SOURCES} ${CHARTSHEET_SOURCES} ${WORKSHEET_SOURCES} ${DETAIL_SOURCES}) if(NOT STATIC) - add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES} $) + add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES}) target_compile_definitions(xlnt PRIVATE XLNT_SHARED=1) if(MSVC) @@ -146,7 +146,7 @@ if(NOT STATIC) ) endif() else() - add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES} $) + add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES} xlnt.third-party) target_compile_definitions(xlnt PUBLIC XLNT_STATIC=1) if(MSVC) @@ -164,6 +164,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE LIBSTUDXML_STATIC_LIB=1 PRIVATE NO_OS_DEPENDENCE=1 PRIVATE CRYPTOPP_DISABLE_ASM=1) +target_link_libraries(${PROJECT_NAME} xlnt.third-party) if(MSVC) set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f49d4965..cc8597d1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,8 +48,9 @@ if(COVERAGE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage") endif() -add_executable(${PROJECT_NAME} ${TEST_HELPERS} ${TESTS} ${RUNNER} $ ${XLNT_ZIP}) +add_executable(${PROJECT_NAME} ${TEST_HELPERS} ${TESTS} ${RUNNER} ${XLNT_ZIP}) target_compile_definitions(${PROJECT_NAME} PRIVATE LIBSTUDXML_STATIC_LIB=1) +target_link_libraries(${PROJECT_NAME} xlnt.third-party) source_group(helpers FILES ${TEST_HELPERS}) source_group(xlnt\\detail FILES ${XLNT_ZIP}) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 851e2b03..1c38dcde 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -93,13 +93,22 @@ if(MINGW OR WIN32) list(APPEND CRYPTOPP ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/winpipes.cpp) endif() +if(NOT MSVC) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/basecode.cpp PROPERTIES + COMPILE_FLAGS "-Wno-unused-private-field") + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rw.cpp PROPERTIES + COMPILE_FLAGS "-Wno-unused-const-variable") + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/filters.cpp PROPERTIES + COMPILE_FLAGS "-Wno-reorder") +endif() + if(NOT MSVC) set_source_files_properties(${ZLIB} PROPERTIES COMPILE_FLAGS "-Wno-implicit-function-declaration") else() set_source_files_properties(${ZLIB} PROPERTIES COMPILE_FLAGS "/wd\"4018\"") endif() -add_library(xlnt.third-party OBJECT +add_library(xlnt.third-party STATIC ${LIBSTUDXML} ${GENX} ${EXPAT}