Skip to content

Commit eb8b08d

Browse files
author
s
committed
Several CMake modernization and MSVC compile fix
1 parent aa6ecb8 commit eb8b08d

6 files changed

Lines changed: 47 additions & 219 deletions

File tree

CMakeLists.txt

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# patches are most welcome! Please send them to the development mailing list.
3838

3939

40-
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
40+
cmake_minimum_required(VERSION 3.6...4.2 FATAL_ERROR)
4141

4242
set (CMAKE_CXX_STANDARD 14)
4343
set (CMAKE_CXX_STANDARD_REQUIRED 11)
@@ -82,46 +82,30 @@ find_package(Threads REQUIRED)
8282

8383
# Find the Boost and Xerces libraries
8484

85-
set(Boost_USE_MULTITHREADED ON)
86-
find_package(Boost
85+
find_package(Boost CONFIG REQUIRED
8786
COMPONENTS
87+
smart_ptr
88+
crc
89+
math
8890
program_options
89-
thread
9091
filesystem
92+
variant
93+
format
94+
lexical_cast
95+
uuid
9196
OPTIONAL_COMPONENTS
9297
system
9398
)
94-
if (NOT Boost_FOUND)
95-
set(BOOST_ROOT CACHE PATH "Location of the boost root directory" )
96-
message(FATAL_ERROR
97-
"Unable to find boost library.
98-
Please set the BOOST_ROOT to point to the boost distribution files."
99-
)
100-
endif(NOT Boost_FOUND)
101-
102-
find_package(Xerces)
103-
if (NOT Xerces_FOUND)
104-
set(XERCES_ROOT CACHE PATH "Location of the xerces library")
105-
message(FATAL_ERROR
106-
"Unable to find xerces library.
107-
Please set the the XERCES_ROOT to point to the root of the xerces directory."
108-
)
109-
endif (NOT Xerces_FOUND)
11099

111-
set(XML_LIBRARIES ${Xerces_LIBRARY})
112-
set(XML_INCLUDE_DIRS ${Xerces_INCLUDE_DIR})
100+
101+
find_package(XercesC REQUIRED)
113102

114103
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
115104
add_definitions(-DLINUX)
116-
find_package(ICU REQUIRED)
117-
set(XML_LIBRARIES ${XML_LIBRARIES} ${ICU_LIBRARIES})
118-
set(XML_INCLUDE_DIRS ${XML_INCLUDE_DIRS} ${ICU_INCLUDE_DIRS})
119105
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
120106
add_definitions(-DWINDOWS)
121107
endif()
122108

123-
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
124-
add_definitions(-DBOOST_ALL_NO_LIB -DXERCES_STATIC_LIBRARY)
125109
add_definitions(-DE57_REFIMPL_REVISION_ID=${PROJECT_NAME}-${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_BUILD_VERSION}-${${PROJECT_NAME}_BUILD_TAG})
126110

127111
configure_file (
@@ -134,12 +118,6 @@ include_directories(
134118
include
135119
include/time_conversion
136120
src/refimpl
137-
${XML_INCLUDE_DIRS}
138-
${Boost_INCLUDE_DIR}
139-
)
140-
141-
link_directories(
142-
${Boost_LIBRARY_DIRS}
143121
)
144122

145123

@@ -161,6 +139,15 @@ set_target_properties( E57RefImpl
161139
PROPERTIES DEBUG_POSTFIX "-d"
162140
)
163141

142+
target_link_libraries( E57RefImpl
143+
PUBLIC
144+
Boost::crc
145+
Boost::smart_ptr
146+
Boost::uuid
147+
Threads::Threads
148+
XercesC::XercesC
149+
)
150+
164151
#
165152
# Files for LAS format support
166153
#
@@ -170,6 +157,11 @@ add_library( LASReader STATIC
170157
include/LASReader.h
171158
)
172159

160+
target_link_libraries( LASReader
161+
PUBLIC
162+
E57RefImpl
163+
)
164+
173165
#
174166
# Time conversion utilities
175167
#
@@ -191,16 +183,12 @@ add_executable( DemoWrite01
191183
)
192184
target_link_libraries( DemoWrite01
193185
E57RefImpl
194-
${XML_LIBRARIES}
195-
${CMAKE_THREAD_LIBS_INIT}
196186
)
197187
add_executable( DemoRead01
198188
src/examples/DemoRead01.cpp
199189
)
200190
target_link_libraries( DemoRead01
201191
E57RefImpl
202-
${XML_LIBRARIES}
203-
${CMAKE_THREAD_LIBS_INIT}
204192
)
205193

206194
#
@@ -214,41 +202,36 @@ target_link_libraries( las2e57
214202
E57RefImpl
215203
LASReader
216204
time_conversion
217-
${XML_LIBRARIES}
218-
${CMAKE_THREAD_LIBS_INIT}
219205
)
220206
add_executable( e57fields
221207
src/tools/e57fields.cpp
222208
)
223209
target_link_libraries( e57fields
224210
E57RefImpl
225-
${XML_LIBRARIES}
226-
${CMAKE_THREAD_LIBS_INIT}
211+
Boost::smart_ptr
227212
)
228213
add_executable( e57xmldump
229214
src/tools/e57xmldump.cpp
230215
)
231216
target_link_libraries( e57xmldump
232217
E57RefImpl
233-
${XML_LIBRARIES}
234-
${CMAKE_THREAD_LIBS_INIT}
235218
)
236219
add_executable( e57validate
237220
src/tools/e57validate.cpp
238221
)
239222
target_link_libraries( e57validate
240223
E57RefImpl
241-
${XML_LIBRARIES}
242-
${CMAKE_THREAD_LIBS_INIT}
243224
)
244225
add_executable( e57unpack
245226
src/tools/e57unpack.cpp
246227
)
247228
target_link_libraries( e57unpack
248229
E57RefImpl
249-
${XML_LIBRARIES}
250-
${Boost_LIBRARIES}
251-
${CMAKE_THREAD_LIBS_INIT}
230+
Boost::filesystem
231+
Boost::format
232+
Boost::lexical_cast
233+
Boost::program_options
234+
Boost::variant
252235
)
253236

254237
#

cmake/Modules/FindICU.cmake

Lines changed: 0 additions & 82 deletions
This file was deleted.

cmake/Modules/FindXerces.cmake

Lines changed: 0 additions & 84 deletions
This file was deleted.

include/E57Simple.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
#include "E57Foundation.h"
5858
#endif
5959

60+
#ifdef WIN32
61+
#include <windows.h>
62+
#endif
63+
6064
using namespace std;
6165
using namespace boost;
6266

src/refimpl/E57RefImplConfig.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ IF (E57RefImpl_LIBRARY_DEBUG AND NOT E57RefImpl_LIBRARY_RELEASE)
116116
SET(E57RefImpl_LIBRARIES ${E57RefImpl_LIBRARY_DEBUG})
117117
ENDIF()
118118

119+
include(CMakeFindDependencyMacro)
120+
find_dependency(Boost COMPONENTS crc smart_ptr uuid)
121+
find_dependency(XercesC)
122+
123+
list(APPEND E57RefImpl_LIBRARIES
124+
Boost::crc
125+
Boost::smart_ptr
126+
Boost::uuid
127+
XercesC::XercesC
128+
)
129+
119130
IF (E57RefImpl_LIBRARY)
120131
set(E57RefImpl_LIBRARY ${E57RefImpl_LIBRARY} CACHE FILEPATH "The E57RefImpl library")
121132
# Remove superfluous "debug" / "optimized" keywords from
@@ -134,7 +145,7 @@ ELSE(E57RefImpl_LIBRARY)
134145
ENDIF(E57RefImpl_LIBRARY)
135146

136147
IF (E57RefImpl_FOUND)
137-
SET(E57RefImpl_INCLUDE_DIRS ${E57RefImpl_INCLUDE_DIR} "E57RefImpl include directory")
148+
SET(E57RefImpl_INCLUDE_DIRS ${E57RefImpl_INCLUDE_DIR})
138149
ENDIF()
139150

140151

src/refimpl/E57SimpleImpl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
# include <sys\stat.h>
5252
# include <windows.h>
5353
//#include <stdint.h> //if you need this then remove <boost/cstdint.hpp> in E57Foundation.h line 48
54-
#pragma warning(disable:4996)
55-
# include <boost/uuid/uuid.hpp>
56-
# include <boost/uuid/uuid_generators.hpp>
57-
# include <boost/uuid/uuid_io.hpp>
5854
# elif defined(__GNUC__)
5955
# define _LARGEFILE64_SOURCE
6056
# define __LARGE64_FILES

0 commit comments

Comments
 (0)