@@ -40,6 +40,7 @@ option(WITH_TFM "Build with support for tomsfastmath" FALSE)
40
40
option (WITH_GMP "Build with support for GNU Multi Precision Arithmetic Library" FALSE )
41
41
set (MPI_PROVIDER "LTM" CACHE STRING "Build tests and demos against 'LTM', 'TFM' or 'GMP', default is LTM" )
42
42
option (BUILD_SHARED_LIBS "Build shared library and only the shared library if \" ON\" , default is static" OFF )
43
+ option (WITH_PTHREAD "Build with pthread support" FALSE )
43
44
44
45
#-----------------------------------------------------------------------------
45
46
# Add support for ccache if desired
@@ -164,8 +165,8 @@ if(WITH_LTM)
164
165
target_compile_definitions (${PROJECT_NAME} PUBLIC USE_LTM)
165
166
endif ()
166
167
target_link_libraries (${PROJECT_NAME} PUBLIC libtommath)
167
- list (APPEND LTC_MPI_PROVIDERS_CFLAGS -DLTM_DESC)
168
- list (APPEND LTC_MPI_PROVIDERS_LIBS -ltommath)
168
+ list (APPEND LTC_PKG_CONFIG_CFLAGS -DLTM_DESC)
169
+ list (APPEND LTC_PKG_CONFIG_LIBS -ltommath)
169
170
list (APPEND LTC_DEBIAN_MPI_PROVIDER_DEPENDS libtommath-dev)
170
171
endif ()
171
172
# tomsfastmath
@@ -177,8 +178,8 @@ if(WITH_TFM)
177
178
target_compile_definitions (${PROJECT_NAME} PUBLIC USE_TFM)
178
179
endif ()
179
180
target_link_libraries (${PROJECT_NAME} PUBLIC tomsfastmath)
180
- list (APPEND LTC_MPI_PROVIDERS_CFLAGS -DTFM_DESC)
181
- list (APPEND LTC_MPI_PROVIDERS_LIBS -ltfm)
181
+ list (APPEND LTC_PKG_CONFIG_CFLAGS -DTFM_DESC)
182
+ list (APPEND LTC_PKG_CONFIG_LIBS -ltfm)
182
183
list (APPEND LTC_DEBIAN_MPI_PROVIDER_DEPENDS libtfm-dev)
183
184
endif ()
184
185
# GNU MP
@@ -190,13 +191,30 @@ if(WITH_GMP)
190
191
target_compile_definitions (${PROJECT_NAME} PUBLIC USE_GMP)
191
192
endif ()
192
193
target_link_libraries (${PROJECT_NAME} PUBLIC ${GMP_LIBRARIES} )
193
- list (APPEND LTC_MPI_PROVIDERS_CFLAGS -DGMP_DESC)
194
- list (APPEND LTC_MPI_PROVIDERS_LIBS -lgmp)
194
+ list (APPEND LTC_PKG_CONFIG_CFLAGS -DGMP_DESC)
195
+ list (APPEND LTC_PKG_CONFIG_LIBS -lgmp)
195
196
list (APPEND LTC_DEBIAN_MPI_PROVIDER_DEPENDS libgmp-dev)
196
197
endif ()
197
198
198
- list (JOIN LTC_MPI_PROVIDERS_CFLAGS " " MPI_PROVIDERS_CFLAGS)
199
- list (JOIN LTC_MPI_PROVIDERS_LIBS " " MPI_PROVIDERS_LIBS)
199
+
200
+ #-----------------------------------------------------------------------------
201
+ # other options
202
+ #-----------------------------------------------------------------------------
203
+
204
+ if (WITH_PTHREAD)
205
+ set (THREADS_PREFER_PTHREAD_FLAG ON )
206
+ find_package (Threads REQUIRED)
207
+ if (CMAKE_USE_PTHREADS_INIT)
208
+ target_compile_definitions (${PROJECT_NAME} PUBLIC LTC_PTHREAD)
209
+ target_link_libraries (${PROJECT_NAME} PRIVATE Threads::Threads)
210
+ list (APPEND LTC_PKG_CONFIG_CFLAGS -DLTC_PTHREAD)
211
+ else ()
212
+ message (SEND_ERROR "pthreads not supported. Reconfigure ${PROJECT_NAME} with -DWITH_PTHREAD=OFF." )
213
+ endif ()
214
+ endif ()
215
+
216
+ list (JOIN LTC_PKG_CONFIG_CFLAGS " " PKG_CONFIG_CFLAGS)
217
+ list (JOIN LTC_PKG_CONFIG_LIBS " " PKG_CONFIG_LIBS)
200
218
list (JOIN LTC_DEBIAN_MPI_PROVIDER_DEPENDS " " DEBIAN_MPI_PROVIDER_DEPENDS)
201
219
202
220
#-----------------------------------------------------------------------------
0 commit comments