Convert-Binary-C

 view release on metacpan or  search on metacpan

tests/include/pdclib/CMakeLists.txt  view on Meta::CPAN

     include/stdarg.h
     include/stdbool.h
     include/stddef.h
     include/stdint.h
     include/stdio.h
     include/stdlib.h
     include/stdnoreturn.h
     include/string.h
     include/time.h
     include/wctype.h

     platform/example/include/float.h
     platform/example/include/signal.h
     platform/example/include/threads.h
)

# These get installed in a "pdclib" subdirectory of your system's default
# "include" directory.
set( PDCLIB_PRIVATE_HEADERS
     include/pdclib/_PDCLIB_glue.h
     include/pdclib/_PDCLIB_internal.h
     include/pdclib/_PDCLIB_lib_ext1.h
     platform/example/include/pdclib/_PDCLIB_config.h
)

# These do not get installed on your system at all, they are for building
# PDCLib only, not for using it.
set( PDCLIB_NOINSTALL_HEADERS
     include/pdclib/_PDCLIB_glue.h
     #include/pdclib/_PDCLIB_tzcode.h
)

# dlmalloc, compiled separately as its inclusion of system headers conflicts
# with PDCLib headers (specifically, struct timespec).
add_library( _dlmalloc OBJECT functions/_dlmalloc/malloc.c )
add_library( _dlmallocs OBJECT functions/_dlmalloc/malloc.c )
target_include_directories( _dlmalloc  PRIVATE ${CMAKE_SOURCE_DIR}/platform/example/include/pdclib )
target_include_directories( _dlmallocs PRIVATE ${CMAKE_SOURCE_DIR}/platform/example/include/pdclib )

# Two libraries, one for dynamic linking, one for static linking.
add_library( pdclib  SHARED ${PDCLIB_SOURCES} $<TARGET_OBJECTS:_dlmalloc>  ${PDCLIB_HEADERS} ${PDCLIB_PRIVATE_HEADERS} ${PDCLIB_NOINSTALL_HEADERS} )
add_library( pdclibs STATIC ${PDCLIB_SOURCES} $<TARGET_OBJECTS:_dlmallocs> ${PDCLIB_HEADERS} ${PDCLIB_PRIVATE_HEADERS} ${PDCLIB_NOINSTALL_HEADERS} )

# The example implementation makes use of pthread. We use CMake facilities
# to locate the pthread library for linking.
set( CMAKE_THREAD_PREFER_PTHREAD 1 )
set( THREADS_PREFER_PTHREAD_FLAG 1 )
find_package( Threads )
if ( NOT CMAKE_USE_PTHREADS_INIT )
    message( FATAL_ERROR "Example platform requires pthread to be available." )
endif()

target_link_libraries( pdclib Threads::Threads )
target_link_libraries( pdclibs Threads::Threads )

# Compilation shall use PDCLib's over system include directories.
target_include_directories( pdclib  BEFORE PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/platform/example/include )
target_include_directories( pdclibs BEFORE PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/platform/example/include )

# The code for the DLL / shared object should be compiled with whatever
# options are appropriate for your compiler to generate relocatable code.
set_property( TARGET pdclib _dlmalloc PROPERTY POSITION_INDEPENDENT_CODE 1 )

# List of strict warnings; the compiler is your friend.
if ( CMAKE_COMPILER_IS_GNUCC )
    # The bit about -D_STDC_PREDEF_H is a heavy-handed way to interdict
    # GCC making statements about the standard library's capabilities,
    # specifically __STDC_NO_THREADS__ (by including stdc-predef.h). I
    # was unable to identify a more elegant way to achieve this.
    set( FLAGS "-Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Winline -Wno-long-long -Wuninitialized -fno-builtin -fvisibility=hidden -D_STDC_PREDEF_H -no...

    if ( NOT AS_CXX )
        string( APPEND FLAGS " -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wdeclaration-after-statement" )
    endif()
elseif( MSVC )
    set( FLAGS "/W4 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
endif()

# Optionally, use C++ compiler instead of C compiler.
if ( AS_CXX )
    set_source_files_properties( ${PDCLIB_SOURCES} PROPERTIES LANGUAGE CXX )
endif()

# Optionally, make TESTCASE( NO_TESTDRIVER ) succeed instead of fail.
if ( IGNORE_NO_TESTDRIVER )
    string( APPEND FLAGS " -DNO_TESTDRIVER=1" )
endif()

# Setting symbol visibility (_PDCLIB_LOCAL / _PDCLIB_PUBLIC configuration
# in _PDCLIB_config.h)
set_property( TARGET pdclib  APPEND_STRING PROPERTY COMPILE_FLAGS "-D_PDCLIB_BUILD ${FLAGS}" )
set_property( TARGET pdclibs APPEND_STRING PROPERTY COMPILE_FLAGS "-D_PDCLIB_STATIC_DEFINE ${FLAGS}" )

# On Windows, both a dynamic .dll and a static .a library require their own
# respective .lib file, which is why the static library has its distinctive
# name pdclibs.a (note the "s").
# On Unix-like OS' (and Cygwin), we can have both .so and .a with the same
# base name, so we do away with the "s" suffix.
if ( UNIX )
    set_target_properties( pdclibs PROPERTIES OUTPUT_NAME pdclib )
endif()

add_custom_target( testdrivers )
add_custom_target( regtestdrivers )

# Each source file can be compiled to
# 1) a test driver for the function it defines,
# 2) a regression test driver for the function as defined by the system's
#    C library.
foreach( file ${PDCLIB_SOURCES} )
    get_filename_component( basename ${file} NAME_WE )

    # Test driver, _t suffix, compiled with -DTEST against static lib.
    add_executable( ${basename}_t ${file} )
    set_property( TARGET ${basename}_t APPEND_STRING PROPERTY COMPILE_FLAGS "-DTEST -D_PDCLIB_BUILD ${FLAGS}" )
    set_property( TARGET ${basename}_t PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test_support/testdrivers )
    target_include_directories( ${basename}_t BEFORE PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/platform/example/include ${CMAKE_SOURCE_DIR}/test_support )
    target_link_libraries( ${basename}_t pdclibs )
    add_test( ${basename}_t test_support/testdrivers/${basename}_t )
    add_dependencies( testdrivers ${basename}_t )



( run in 0.514 second using v1.01-cache-2.11-cpan-71847e10f99 )