Skip to content

Commit

Permalink
Windows Build with cmake first step
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Jan 2, 2018
1 parent bd73e3a commit cfd3658
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
16 changes: 14 additions & 2 deletions CMakeLists.txt
Expand Up @@ -20,7 +20,9 @@
cmake_minimum_required(VERSION 3.0)
project(bareos)

if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
include_directories(/usr/include)
endif()

set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
Expand Down Expand Up @@ -73,6 +75,17 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "HP-UX")
link_libraries(dld intl)
endif()

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DMINGW64 -DHAVE_WIN32 -DHAVE_MINGW -D_WIN32_WINNT=0x600)
# add_definitions(-DMINGW64 -DHAVE_WIN32 -DHAVE_MINGW -D_WIN32_WINNT=0x600 -D_BDB_PRIV_INTERFACE_ -Wall -m64 -mwin32 -mthreads)
include_directories(${CMAKE_SOURCE_DIR}/src/win32/include ${CMAKE_SOURCE_DIR}/src/win32/compat/include)
set(HAVE_WIN32 1)
link_directories(/usr/x86_64-w64-mingw32/sys-root/mingw/lib)
set(WINDOWS_LIBRARIES ws2_32)
else()
add_definitions("-D_FILE_OFFSET_BITS=64")
endif()

INCLUDE(BareosFindPrograms)

INCLUDE(GNUInstallDirs)
Expand All @@ -99,7 +112,7 @@ mark_as_advanced(INSTALL_LIB_DIR)


# RPATH settings (from https://cmake.org/Wiki/CMake_RPATH_handling)
# use, i.e. don't skip the full RPATH for the build tree
# use, i.e. don')t skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
Expand Down Expand Up @@ -147,7 +160,6 @@ ELSE()
ENDIF()


add_definitions("-D_FILE_OFFSET_BITS=64")

MESSAGE( STATUS "VERSION: " ${CMAKE_MATCH_1} )

Expand Down
13 changes: 11 additions & 2 deletions src/findlib/CMakeLists.txt
Expand Up @@ -21,15 +21,24 @@ include_directories(../include .. .)

SET(BAREOSFIND_SRCS acl.cc attribs.cc bfile.cc create_file.cc drivetype.cc
enable_priv.cc find_one.cc find.cc fstype.cc hardlink.cc match.cc
mkpath.cc savecwd.cc shadowing.cc xattr.cc)
mkpath.cc shadowing.cc xattr.cc)

IF(${HAVE_WIN32})
LIST(APPEND BAREOSFIND_SRCS ../win32/findlib/win32.cc)
ELSE()
LIST(APPEND BAREOSFIND_SRCS savecwd.cc)
ENDIF()


add_library(bareosfind SHARED ${BAREOSFIND_SRCS})
target_link_libraries(bareosfind ${ACL_LIBS})

target_link_libraries(bareosfind bareos ${ACL_LIBS})

INSTALL(TARGETS bareosfind DESTINATION ${libdir})

set_target_properties(bareosfind PROPERTIES VERSION "${VERSION}"
SOVERSION "${SOVERSION}"
DEFINE_SYMBOL "BUILDING_DLL"
)

add_subdirectory(unittests)
29 changes: 26 additions & 3 deletions src/lib/CMakeLists.txt
Expand Up @@ -52,30 +52,53 @@ set (BAREOS_SRCS address_conf.cc alist.cc attr.cc attribs.cc base64.cc
jcr.cc json.cc lockmgr.cc md5.cc mem_pool.cc message.cc mntent_cache.cc
output_formatter.cc passphrase.cc path_list.cc plugins.cc poll.cc priv.cc
queue.cc rblist.cc runscript.cc rwlock.cc scan.cc scsi_crypto.cc scsi_lli.cc
scsi_tapealert.cc sellist.cc serial.cc sha1.cc signal.cc smartall.cc
sellist.cc serial.cc sha1.cc signal.cc smartall.cc
tls_gnutls.cc tls_none.cc tls_nss.cc tls_openssl.cc tree.cc util.cc var.cc
watchdog.cc workq.cc)

IF(${HAVE_WIN32})
LIST(APPEND BAREOS_SRCS
../win32/compat/compat.cc
../win32/compat/glob.cc
../win32/compat/print.cc
../win32/compat/winapi.cc
)
ELSE()
LIST(APPEND BAREOS_SRCS
scsi_tapealert.cc)
ENDIF()

add_library(bareos SHARED ${BAREOS_SRCS})

target_link_libraries(bareos
${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES} ${FASTLZ_LIBRARIES} ${ZLIB_LIBRARIES}
${ACL_LIBRARIES} ${LZO2_LIBRARIES} ${CAP_LIBRARIES} ${WRAP_LIBRARIES} ${CAM_LIBRARIES})
${ACL_LIBRARIES} ${LZO2_LIBRARIES} ${CAP_LIBRARIES} ${WRAP_LIBRARIES} ${CAM_LIBRARIES}
${WINDOWS_LIBRARIES} ${JANSSON_LIBRARIES})

set (BAREOSCFG_SRCS ini.cc lex.cc parse_bsr.cc )

set (BAREOSCFG_SRCS ini.cc lex.cc parse_bsr.cc parse_conf.cc res.cc)

add_library(bareoscfg SHARED ${BAREOSCFG_SRCS})
target_link_libraries(bareoscfg ${JANSSON_LIBRARIES})

set (BAREOS_STATIC_SRCS parse_conf.cc res.cc)
add_library(bareosstatic STATIC ${BAREOS_STATIC_SRCS})


INSTALL(TARGETS bareos DESTINATION ${libdir})
INSTALL(TARGETS bareoscfg DESTINATION ${libdir})

set_target_properties(bareoscfg PROPERTIES VERSION "${VERSION}"
SOVERSION "${SOVERSION}"
DEFINE_SYMBOL "BUILDING_DLL"
)
#LINK_FLAGS -Wl,--out-implib,bareoscfg.a

set_target_properties(bareos PROPERTIES VERSION "${VERSION}"
SOVERSION "${SOVERSION}"
DEFINE_SYMBOL "BUILDING_DLL"
)
#LINK_FLAGS -Wl,--out-implib,bareos.a

INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${includedir})

Expand Down
2 changes: 2 additions & 0 deletions src/lib/unittests/CMakeLists.txt
Expand Up @@ -19,6 +19,8 @@

include_directories(.. ../.. ../../include/)

link_libraries(kernel32 user32 gdi32 winspool shell32 ole32 oleaut32 uuid comdlg32 advapi32)

set (TEST_SRC
alist_test.cc
dlist_test.cc
Expand Down
3 changes: 2 additions & 1 deletion src/lib/unittests/alist_test.cc
Expand Up @@ -27,7 +27,8 @@
* Philipp Storz, November 2017
*/

#include "bareos.h"
//#include "bareos.h"
#include "windows.h"
#include "gtest/gtest.h"

struct FILESET {
Expand Down
1 change: 0 additions & 1 deletion src/win32/compat/include/compat.h
Expand Up @@ -29,7 +29,6 @@
* Created On : Fri Jan 30 13:00:51 2004
*/


#if !defined(__COMPAT_H_)
#define __COMPAT_H_
#if !defined(_STAT_H)
Expand Down

0 comments on commit cfd3658

Please sign in to comment.