364ccb6cefe5f9039a698c7feacf83769e5055cb
[blender.git] / build_files / build_environment / cmake / pthreads.cmake
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ***** END GPL LICENSE BLOCK *****
18
19 if(WIN32)
20                 set(PTHREAD_XCFLAGS /MD)
21
22                 if(MSVC14) # vs2015 has timespec
23                         set(PTHREAD_CPPFLAGS "/I. /DHAVE_CONFIG_H /D_TIMESPEC_DEFINED ")
24                 else() # everything before doesn't
25                         set(PTHREAD_CPPFLAGS "/I. /DHAVE_CONFIG_H ")
26                 endif()
27
28                 set(PTHREADS_BUILD cd ${BUILD_DIR}/pthreads/src/external_pthreads/ && cd && nmake VC /e CPPFLAGS=${PTHREAD_CPPFLAGS} /e XCFLAGS=${PTHREAD_XCFLAGS} /e XLIBS=/NODEFAULTLIB:msvcr)
29
30                 ExternalProject_Add(external_pthreads
31                         URL ${PTHREADS_URI}
32                         DOWNLOAD_DIR ${DOWNLOAD_DIR}
33                         URL_HASH MD5=${PTHREADS_HASH}
34                         PREFIX ${BUILD_DIR}/pthreads
35                         CONFIGURE_COMMAND echo .
36                         BUILD_COMMAND ${PTHREADS_BUILD}
37                         INSTALL_COMMAND COMMAND
38                                 ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthreadVC3.dll ${LIBDIR}/pthreads/lib/pthreadVC3.dll &&
39                                 ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthreadVC3${LIBEXT} ${LIBDIR}/pthreads/lib/pthreadVC3${LIBEXT} &&
40                                 ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthread.h ${LIBDIR}/pthreads/inc/pthread.h &&
41                                 ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/sched.h ${LIBDIR}/pthreads/inc/sched.h &&
42                                 ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/semaphore.h ${LIBDIR}/pthreads/inc/semaphore.h &&
43                                 ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/_ptw32.h ${LIBDIR}/pthreads/inc/_ptw32.h
44                         INSTALL_DIR ${LIBDIR}/pthreads
45                 )
46
47                 if(BUILD_MODE STREQUAL Release)
48                         ExternalProject_Add_Step(external_pthreads after_install
49                                 COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/inc/ ${HARVEST_TARGET}/pthreads/include/
50                                 COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/lib/ ${HARVEST_TARGET}/pthreads/lib
51                                 DEPENDEES install
52                         )
53                 endif()
54
55 endif()