Skip to content

Commit

Permalink
Add back windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Oct 11, 2024
1 parent 6713e05 commit 07d52a3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 52 deletions.
124 changes: 74 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,45 +38,49 @@ include_directories (lib)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-unknown-pragmas")

if (DEFINED STATIC_BUILD)
# dependencies from install_dependencies.sh should be in ${PROJECT_SOURCE_DIR}/dependencies/build/
set (EXT_LIB_PATH "${PROJECT_SOURCE_DIR}/dependencies/build")
message("EXT_LIB_PATH: ${EXT_LIB_PATH}")

# Set the CMAKE_PREFIX_PATH to search for libraries
set (CMAKE_PREFIX_PATH "${EXT_LIB_PATH}")
message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")

# static libraries for boost
set (Boost_USE_STATIC_LIBS ON)
# set (BUILD_SHARED_LIBS OFF)
# set (CMAKE_EXE_LINKER_FLAGS "-static")
# set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
# set (CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
# set (CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
# set (CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
# set (CMAKE_SHARED_LIBRARY_CXX_FLAGS)
# set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
# set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
# Hard coded libraries
set (HARD_CODED_LIBRARIES
${EXT_LIB_PATH}/lib/libbz2.a
${EXT_LIB_PATH}/lib/libcares.a
${EXT_LIB_PATH}/lib/libz.a
)
find_package(OpenSSL)
if(OPENSSL_FOUND)
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
include_directories(${OPENSSL_INCLUDE_DIR})
message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
list (APPEND HARD_CODED_LIBRARIES
${OPENSSL_LIBRARIES} -ldl
if (WINDOWS)
set (Boost_USE_STATIC_LIBS ON) # only find static libs
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") # also requires boost with runtime-link=static
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") # also requires boost with runtime-link=static
add_definitions(-DCURL_STATICLIB) # Needed to statically link libcurl
add_definitions(-DNOMINMAX) # Needed to suppress min and max definitions by Windows

set (THIRD_PARTY_LIBRARIES
dependencies/curl/lib/libcurl
${CMAKE_THREAD_LIBS_INIT}
)
else()
list (APPEND HARD_CODED_LIBRARIES
${EXT_LIB_PATH}/lib/libssl.a
${EXT_LIB_PATH}/lib/libcrypto.a
-ldl
)
# dependencies from install_dependencies.sh should be in ${PROJECT_SOURCE_DIR}/dependencies/build/
set (EXT_LIB_PATH "${PROJECT_SOURCE_DIR}/dependencies/build")
message("EXT_LIB_PATH: ${EXT_LIB_PATH}")

# Set the CMAKE_PREFIX_PATH to search for libraries
set (CMAKE_PREFIX_PATH "${EXT_LIB_PATH}")
message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")

# static libraries for boost
set (Boost_USE_STATIC_LIBS ON)
# Hard coded libraries
set (HARD_CODED_LIBRARIES
${EXT_LIB_PATH}/lib/libbz2.a
${EXT_LIB_PATH}/lib/libcares.a
${EXT_LIB_PATH}/lib/libz.a
)
find_package(OpenSSL)
if(OPENSSL_FOUND)
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
include_directories(${OPENSSL_INCLUDE_DIR})
message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
list (APPEND HARD_CODED_LIBRARIES
${OPENSSL_LIBRARIES} -ldl
)
else()
list (APPEND HARD_CODED_LIBRARIES
${EXT_LIB_PATH}/lib/libssl.a
${EXT_LIB_PATH}/lib/libcrypto.a
-ldl
)
endif()
endif()
else()
# Dynamic libraries for boost
Expand All @@ -102,12 +106,19 @@ message("CURL_LIBRARIES: ${CURL_LIBRARIES}")
message("HARD_CODED_LIBRARIES: ${HARD_CODED_LIBRARIES}")
message("CMAKE_THREAD_LIBS_INIT: ${CMAKE_THREAD_LIBS_INIT}")

set (THIRD_PARTY_LIBRARIES
${Boost_LIBRARIES}
${CURL_LIBRARIES}
${HARD_CODED_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
if (WINDOWS)
set (THIRD_PARTY_LIBRARIES
dependencies/curl/lib/libcurl
${CMAKE_THREAD_LIBS_INIT}
)
else()
set (THIRD_PARTY_LIBRARIES
${Boost_LIBRARIES}
${CURL_LIBRARIES}
${HARD_CODED_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
endif ()


set (MOD_VCF_SOURCES
Expand Down Expand Up @@ -155,13 +166,26 @@ set (MOD_VCF_SOURCES
add_library (mod_vcf STATIC ${MOD_VCF_SOURCES})
target_link_libraries (mod_vcf ${THIRD_PARTY_LIBRARIES})

set (LIBRARIES_TO_LINK
mod_vcf
${Boost_LIBRARIES}
${CURL_LIBRARIES}
dl
${CMAKE_THREAD_LIBS_INIT}
)
if (WINDOWS)
set (LIBRARIES_TO_LINK
mod_vcf
dependencies/curl/lib/libcurl
ws2_32
crypt32
Wldap32
Normaliz
${CMAKE_THREAD_LIBS_INIT}
)
else()
set (LIBRARIES_TO_LINK
mod_vcf
${Boost_LIBRARIES}
${CURL_LIBRARIES}
dl
${CMAKE_THREAD_LIBS_INIT}
)
endif ()


# Build tests
set (V41_TESTS test/vcf/parser_v41_test.cpp)
Expand Down
4 changes: 2 additions & 2 deletions install_dependencies.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off

if not exist windows_dependencies mkdir windows_dependencies
cd windows_dependencies
if not exist dependencies mkdir dependencies
cd dependencies

:: Download zip files
powershell -command "(new-object System.Net.WebClient).DownloadFile('https://curl.haxx.se/download/curl-7.62.0.zip','curl-7.62.0.zip')"
Expand Down

0 comments on commit 07d52a3

Please sign in to comment.