@@ -9,7 +9,19 @@ project (lib3MF)
9
9
# Define Version
10
10
set (LIB3MF_VERSION_MAJOR 1) # increase on every backward-compatibility breaking change of the API
11
11
set (LIB3MF_VERSION_MINOR 3) # increase on every backward compatible change of the API
12
- set (LIB3MF_VERSION_MICRO 0) # increase on on every change that does not alter the API
12
+ set (LIB3MF_VERSION_MICRO 1) # increase on on every change that does not alter the API
13
+
14
+
15
+ # Add targets
16
+ # By default the shared libray is being built
17
+ # To build the static library, add the cmake option -DBUILD_SHARED_LIBS:BOOL=OFF
18
+ option (BUILD_SHARED_LIBS "build as shared library" ON )
19
+ message ("BUILD_SHARED_LIBS ... " ${BUILD_SHARED_LIBS} )
20
+
21
+ # By default the tests of the library are being built
22
+ # To not build the tests, use cmake . -DBUILD_TESTING:BOOL=OFF
23
+ option (BUILD_TESTING "build the tests of the library" ON )
24
+ message ("BUILD_TESTING ... " ${BUILD_TESTING} )
13
25
14
26
set (CMAKE_INSTALL_BINDIR bin CACHE PATH "directory for installing binary files" )
15
27
set (CMAKE_INSTALL_LIBDIR lib CACHE PATH "directory for installing library files" )
@@ -32,6 +44,8 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
32
44
add_definitions (-DBUILD_DLL -DLIB3MF_EXPORTS /W3)
33
45
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} xmllite.lib" )
34
46
add_definitions (-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
47
+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT" )
48
+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd" )
35
49
if (NMR_COM_NATIVE)
36
50
add_definitions (-DNMR_COM_NATIVE)
37
51
endif ()
@@ -91,44 +105,28 @@ endif()
91
105
92
106
93
107
#########################################################
94
- # Static library (as base for other targets)
95
- add_library (${PROJECT_NAME} _s STATIC ${SRCS_MAIN_PLATFORM} ${SRCS_COMMON} )
96
- target_include_directories (${PROJECT_NAME} _s PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /Include )
97
- target_include_directories (${PROJECT_NAME} _s PUBLIC ${CMAKE_CURRENT_BINARY_DIR} /Include )
98
- SET_TARGET_PROPERTIES (${PROJECT_NAME} _s PROPERTIES PREFIX "" IMPORT_PREFIX "" )
99
- if (UNIX OR MINGW)
100
- target_compile_options (${PROJECT_NAME} _s PUBLIC "-fPIC" )
101
- # Uncomment the following to but the version info into the .so-file.
102
- SET_TARGET_PROPERTIES (${PROJECT_NAME} _s PROPERTIES VERSION "${LIB3MF_VERSION_MAJOR} .${LIB3MF_VERSION_MINOR} .${LIB3MF_VERSION_MICRO} .${BUILD_NUMBER} " )
103
- SET_TARGET_PROPERTIES (${PROJECT_NAME} _s PROPERTIES SOVERSION "${LIB3MF_VERSION_MAJOR} " )
104
- if (NOT APPLE )
105
- SET_TARGET_PROPERTIES (${PROJECT_NAME} _s PROPERTIES LINK_FLAGS -s)
106
- endif ()
107
- find_library (LIBUUID_PATH uuid)
108
- if (NOT LIBUUID_PATH)
109
- message (FATAL_ERROR "libuuid not found" )
110
- endif ()
111
- target_link_libraries (${PROJECT_NAME} _s ${LIBUUID_PATH} )
112
- else ()
113
- # wd4996 masks the deprecated-warning
114
- target_compile_options (${PROJECT_NAME} _s PUBLIC "$<$<CONFIG:DEBUG>:/Od;/Ob0;/Gm;/sdl;/W3;/WX;/FC;/wd4996>" )
115
- target_compile_options (${PROJECT_NAME} _s PUBLIC "$<$<CONFIG:RELEASE>:/O2;/sdl;/WX;/Oi;/Gy;/FC;/wd4996>" )
116
- endif ()
117
-
118
-
119
- #########################################################
120
- # Shared library
121
- add_library (${PROJECT_NAME} SHARED ${SRCS_MAIN_PLATFORM}
122
- "./Source/Model/COM/NMR_DLLInterfaces.cpp"
108
+ # The main lib3MF library
109
+ add_library (${PROJECT_NAME}
110
+ ${SRCS_MAIN_PLATFORM} ${SRCS_COMMON}
123
111
${VERSION_FILES_OUTPUTLOCATION}
124
112
)
113
+ target_include_directories (${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /Include )
114
+ target_include_directories (${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} /Include )
125
115
set (STARTUPPROJECT ${PROJECT_NAME} )
126
116
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES PREFIX "" IMPORT_PREFIX "" )
127
- target_link_libraries (${PROJECT_NAME} ${PROJECT_NAME} _s)
128
117
if (UNIX OR MINGW)
129
118
# Uncomment the following to but the version info into the .so-file.
130
119
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES VERSION "${LIB3MF_VERSION_MAJOR} .${LIB3MF_VERSION_MINOR} .${LIB3MF_VERSION_MICRO} .${BUILD_NUMBER} " )
131
120
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES SOVERSION "${LIB3MF_VERSION_MAJOR} " )
121
+
122
+ find_library (LIBUUID_PATH uuid)
123
+ if (NOT LIBUUID_PATH)
124
+ message (FATAL_ERROR "libuuid not found" )
125
+ endif ()
126
+ target_link_libraries (${PROJECT_NAME} ${LIBUUID_PATH} )
127
+ if (NOT APPLE )
128
+ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES LINK_FLAGS -s)
129
+ endif ()
132
130
endif ()
133
131
install (TARGETS ${PROJECT_NAME}
134
132
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR} "
@@ -138,30 +136,25 @@ install(DIRECTORY Include/Model DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
138
136
install (DIRECTORY Include /Common DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} " )
139
137
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /Include / DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} " )
140
138
139
+
141
140
#########################################################
142
- if (NOT DEFINED LIB3MF_TESTS)
143
- set (LIB3MF_TESTS TRUE )
144
- endif ()
145
- message ("LIB3MF_TESTS ... " ${LIB3MF_TESTS} )
146
- if (LIB3MF_TESTS)
141
+ if (${BUILD_TESTING} )
147
142
include (CTest)
148
143
# platform independent tests on the C-interface of the library
149
144
add_subdirectory (UnitTests)
150
145
151
- # windows specific tests
146
+ # windows specific tests for the C++ classes of the library
152
147
if (WIN32 )
153
148
SET (UNITTEST_NAME "${PROJECT_NAME} unittests" )
154
- add_library (${UNITTEST_NAME} SHARED "${SRCS_WIN_MANAGEDTEST} " )
149
+ add_library (${UNITTEST_NAME} SHARED ${SRCS_MAIN_PLATFORM} ${SRCS_COMMON} ${SRCS_WIN_MANAGEDTEST} )
150
+
155
151
target_include_directories (${UNITTEST_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /Include )
156
152
target_include_directories (${UNITTEST_NAME} PUBLIC "${VCINSTALLDIR} /../../../UnitTest/include" )
157
153
target_include_directories (${UNITTEST_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} /Include )
158
154
159
155
target_compile_options (${UNITTEST_NAME} PUBLIC "$<$<CONFIG:DEBUG>:/Od;/Ob0;/Gm;/sdl;/W3;/WX;/FC;-DNMR_USEASSERTIONS;-DNMR_UNITTESTS;/wd4996>" )
160
156
target_compile_options (${UNITTEST_NAME} PUBLIC "$<$<CONFIG:RELEASE>:/O2;/sdl;/WX;/Oi;/Gy;/FC;/wd4996>" )
161
157
162
- add_dependencies (${UNITTEST_NAME} ${PROJECT_NAME} _s)
163
- target_link_libraries (${UNITTEST_NAME} ${PROJECT_NAME} _s)
164
-
165
158
file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /TestOutput" )
166
159
endif ()
167
160
endif ()
0 commit comments