Skip to content

Commit 0865384

Browse files
Merge pull request #407 from nexusformat/Issue404_WindowsCMakeBuild
Issue404 windows c make build Fixes #404
2 parents c6ec838 + a869d77 commit 0865384

11 files changed

Lines changed: 66 additions & 11 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Makefile
1212
cmake_install.cmake
1313
install_manifest.txt
1414

15-
15+
# Ignore usual in-tree CMake build area
16+
/build/
1617

1718
# Compiled Object files
1819
*.slo

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ add_custom_target(html)
5151
if(CMAKE_HOST_UNIX)
5252
#easy on Unix - just follow the GNU standard
5353
include(GNUInstallDirs)
54-
endif()
54+
else()
55+
set(CMAKE_INSTALL_LIBDIR lib)
56+
set(CMAKE_INSTALL_DOCDIR doc)
57+
set(CMAKE_INSTALL_INCLUDEDIR include)
58+
set(CMAKE_INSTALL_MANDIR man)
59+
set(CMAKE_INSTALL_BINDIR bin)
60+
endif()
5561

5662

5763
#-----------------------------------------------------------------------------

README.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,34 @@ programs (if configured to build them). To build the API documentation use
124124
125125
$ make html
126126
$ make install-html
127+
128+
Building the code on Windows
129+
============================
130+
131+
These instructions will build everything except the applications using LIBXML2 (e.g. nxtranslate)
132+
133+
* Download and install HDF4 and/or HDF5 libraries from HDF web site
134+
135+
- within these installations is a "cmake" directory, I needed to remove/rename this to get everything to configure properly
136+
137+
* Download MXML source from http://www.msweet.org/projects.php?Z3
138+
139+
- open the vcnet directory
140+
- you need to edit mxml1.def and a add a single line containing the text mxml_error to the end of this file
141+
- open the visual studio solution and build the project
142+
- copy the files mxml.h mxml1.lib mxml1.dll to some other location
143+
144+
* Define HDF4_ROOT, HDF5_ROOT and MXML_ROOT environment variables to point to the top of each installed area
145+
146+
- you should use / rather than \\ for the paths specified in these variables
147+
148+
* Create an empty build directory somewhere - this can be within your nexus source tree
149+
* Run CMAKE-GUI to generate Visual studio solutions files
150+
151+
- Provide source and build paths in the relevant boxes
152+
- Click on Configure, choose appropriate visual studio version when prompted
153+
- A list of options will appear, choose the appropriate ENABLE_ ones and press Configure again
154+
- If nothing is red, click on Generate
155+
156+
* Browse to the build directory and open the generated NeXus.sln
157+
* Build the solution

cmake_include/FindHDF4.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727

2828
set(HDF4_LIBRARIES df mfhdf)
2929

30-
find_library(HDF4_LIBRARIES NAMES df mfhdf PATH_SUFFIXES hdf)
30+
find_library(HDF4_LIBRARIES NAMES df mfhdf HINTS ENV HDF4_ROOT PATH_SUFFIXES hdf)
3131

32-
find_library(_HDF4_DF_LIBRARY NAMES df PATH_SUFFIXES hdf)
32+
find_library(_HDF4_DF_LIBRARY NAMES df hdf HINTS ENV HDF4_ROOT PATH_SUFFIXES hdf)
3333
get_filename_component(HDF4_LIBRARY_DIRS ${_HDF4_DF_LIBRARY} PATH)
3434

35-
find_path ( HDF4_INCLUDE_DIR mfhdf.h PATH /usr/include /usr/include/hdf)
35+
find_path ( HDF4_INCLUDE_DIR mfhdf.h PATH /usr/include /usr/include/hdf HINTS ENV HDF4_ROOT)
3636

3737
include ( FindPackageHandleStandardArgs )
3838
find_package_handle_standard_args( HDF4 DEFAULT_MSG HDF4_LIBRARIES HDF4_INCLUDE_DIR )
@@ -51,6 +51,6 @@ find_package(JPEG REQUIRED)
5151
#------------------------------------------------------------------------------
5252
# add libraries to the link list for NAPI
5353
#------------------------------------------------------------------------------
54-
list(APPEND NAPI_LINK_LIBS df mfhdf jpeg)
54+
list(APPEND NAPI_LINK_LIBS ${_HDF4_DF_LIBRARY} mfhdf jpeg)
5555
include_directories ( SYSTEM ${HDF4_INCLUDE_DIR} )
5656
link_directories(${HDF4_LIBRARY_DIRS})

cmake_include/FindMXML.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#==============================================================================
2727

2828
find_module(MXML
29-
LIB_NAMES mxml
29+
LIB_NAMES mxml mxml1
3030
HEADER_NAMES mxml.h
3131
MOD_NAME mxml)
3232

@@ -36,4 +36,4 @@ if(NOT HAVE_MXML)
3636
message(FATAL_ERROR "User requested MXML not found!")
3737
endif()
3838

39-
list(APPEND NAPI_LINK_LIBS mxml)
39+
list(APPEND NAPI_LINK_LIBS ${MXML_LIBFILES})

cmake_include/Utilities.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ endfunction()
125125
# to look for the module. The name of the module is passed via the
126126
# MOD_NAME keywoard argument.
127127
# 3.) If no pkg-config module is available, the function looks in the
128-
# default search paths.
128+
# default search paths. It can use the environment variable
129+
# ${MOD_NAME}_ROOT as a path hint.
129130
#
130131
# Arguments:
131132
# Positional arguments:
@@ -193,7 +194,7 @@ function(find_module VAR )
193194

194195
#if pkg-config was not successful we have to do this the hard way
195196
if(NOT ${VAR}_FOUND)
196-
find_library(${VAR}_LIBFILES NAME ${LIB_NAMES} PATHS)
197+
find_library(${VAR}_LIBFILES NAME ${LIB_NAMES} PATHS ENV ${MOD_NAME}_ROOT)
197198
if(${${VAR}_LIBFILES} MATCHES "${VAR}_LIBFILES-NOTFOUND")
198199
set(STATUS "Could not find ${VAR} runtime binaries!")
199200
set(HAVE_${VAR} FALSE PARENT_SCOPE)
@@ -203,7 +204,7 @@ function(find_module VAR )
203204
message(STATUS "${VAR} libraries: ${${VAR}_LIBFILES}")
204205
endif()
205206

206-
find_file(${VAR}_HDRFILES NAME ${HEADER_NAMES} PATHS)
207+
find_file(${VAR}_HDRFILES NAME ${HEADER_NAMES} PATHS ENV ${MOD_NAME}_ROOT)
207208
if(${${VAR}_HDRFILES} MATCHES "${VAR}_HDRFILES-NOTFOUND")
208209
message(STATUS "Could not find ${VAR} header files!")
209210
set(HAVE_${VAR} FALSE PARENT_SCOPE)

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727

2828
add_definitions(-DIN_NEXUS_LIBRARY=1 ${NX_CPP})
2929

30+
# this means a static nexus library will use a DLL HDF5. OK for now,
31+
# but may want to change later.
32+
if (WIN32)
33+
add_definitions(-DH5_BUILT_AS_DYNAMIC_LIB=1)
34+
endif (WIN32)
35+
3036
#-----------------------------------------------------------------------------
3137
# generate list of common source files
3238
#-----------------------------------------------------------------------------

test/leak_test1.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <stdio.h>
2+
#ifndef _WIN32
23
#include <unistd.h>
4+
#endif
35
#include <stdlib.h>
46
#include <napi.h>
57

test/leak_test2.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <cstdlib>
44
#include <cstdio>
55
#include <napi.h>
6+
#ifndef _WIN32
67
#include <unistd.h>
8+
#endif /* _WIN32 */
79

810
#define PSZ(s) (s).c_str()
911

test/leak_test3.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include <iostream>
33
#include <stdlib.h>
44
#include <sstream>
5+
#ifndef _WIN32
56
#include <unistd.h>
7+
#endif /* _WIN32 */
68
#include <napi.h>
79

810
#define PSZ(s) (s).c_str()

0 commit comments

Comments
 (0)