@@ -33,18 +33,18 @@ include (target_arch)
3333
3434get_target_arch(TARGET_ARCH)
3535
36- if (${ TARGET_ARCH} STREQUAL "ARM" )
36+ if (TARGET_ARCH STREQUAL "ARM" )
3737 add_definitions (-DPTW32_ARCHARM -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1)
38- elseif (${ TARGET_ARCH} STREQUAL "ARM64" )
38+ elseif (TARGET_ARCH STREQUAL "ARM64" )
3939 add_definitions (-DPTW32_ARCHARM64 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1)
40- elseif (${ TARGET_ARCH} STREQUAL "x86_64" )
40+ elseif (TARGET_ARCH STREQUAL "x86_64" )
4141 add_definitions (-DPTW32_ARCHAMD64)
42- elseif (${ TARGET_ARCH} STREQUAL "x86" )
42+ elseif (TARGET_ARCH STREQUAL "x86" )
4343 add_definitions (-DPTW32_ARCHX86)
44- elseif (${ TARGET_ARCH} STREQUAL "x64" )
44+ elseif (TARGET_ARCH STREQUAL "x64" )
4545 add_definitions (-DPTW32_ARCHX64)
4646else ()
47- MESSAGE (ERROR "\" ${TARGET_ARCH} \" not supported in version.rc" )
47+ MESSAGE (FATAL_ERROR "\" ${TARGET_ARCH} \" not supported in version.rc" )
4848endif ()
4949message (STATUS "Target ............ ${TARGET_ARCH} " )
5050
@@ -55,10 +55,12 @@ endif()
5555#################################
5656# Install Path #
5757#################################
58- if (DIST_ROOT)
59- set (CMAKE_INSTALL_PREFIX "${DIST_ROOT} " )
60- else ()
61- set (CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR} /PTHREADS-BUILT" )
58+ if (NOT DEFINED CMAKE_INSTALL_PREFIX )
59+ if (DIST_ROOT)
60+ set (CMAKE_INSTALL_PREFIX "${DIST_ROOT} " )
61+ else ()
62+ set (CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR} /PTHREADS-BUILT" )
63+ endif ()
6264endif ()
6365message (STATUS "Install Path ${CMAKE_INSTALL_PREFIX} " )
6466
@@ -141,19 +143,34 @@ macro(static_lib type def)
141143 endif ()
142144endmacro ()
143145
144- shared_lib ( VCE PTW32_CLEANUP_CXX )
145- shared_lib ( VSE PTW32_CLEANUP_SEH )
146- shared_lib ( VC PTW32_CLEANUP_C )
147146
148- static_lib ( VCE PTW32_CLEANUP_CXX )
149- static_lib ( VSE PTW32_CLEANUP_SEH )
150- static_lib ( VC PTW32_CLEANUP_C )
147+ option (PTHREAD_BUILD_SHARED_LIBRARY "Build shared library" OFF )
148+ set (_build_shared_library ${PTHREAD_BUILD_SHARED_LIBRARY} )
149+ set (PTHREAD_BUILD_TYPE "VC" CACHE STRING "VC/VSE/VCE" )
150+
151+ if (PTHREAD_BUILD_TYPE STREQUAL "VC" )
152+ set (def_ PTW32_CLEANUP_C)
153+ elseif (PTHREAD_BUILD_TYPE STREQUAL "VSE" OR PTHREAD_BUILD_TYPE STREQUAL "VCE" )
154+ set (def_ PTW32_CLEANUP_C)
155+ else ()
156+ message (FATAL_ERROR "Unsupported pthread type ${PTHREAD_BUILD_TYPE} " )
157+ endif ()
158+
159+ if (_build_shared_library)
160+ shared_lib (${PTHREAD_BUILD_TYPE} PTW32_CLEANUP_C)
161+ else ()
162+ static_lib (${PTHREAD_BUILD_TYPE} PTW32_CLEANUP_C)
163+ endif ()
151164
152165#################################
153166# Install #
154167#################################
155168install (FILES _ptw32.h pthread.h sched.h semaphore.h DESTINATION ${HDRDEST} )
156169
170+ message (STATUS "DLLDEST = ${DLLDEST} " )
171+ message (STATUS "LIBDEST = ${LIBDEST} " )
172+ message (STATUS "HDRDEST = ${HDRDEST} " )
173+
157174#################################
158175# Test #
159176#################################
@@ -162,4 +179,6 @@ option(ENABLE_TESTS "Enable Test code build" FALSE)
162179#TODO determine if cross compile...
163180if (ENABLE_TESTS)
164181 add_subdirectory (tests)
182+
183+ message (STATUS "TESTDEST = ${TESTDEST} " )
165184endif ()
0 commit comments