1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
project( wibble )
include( test.cmake )
include( CheckCXXSourceCompiles )
check_cxx_source_compiles(
"#include <dirent.h>
int main() {
struct dirent *d;
(void)d->d_type;
return 0;
}" HAVE_STRUCT_DIRENT_D_TYPE )
configure_file( ${wibble_SOURCE_DIR}/config.h.cmake-in ${wibble_BINARY_DIR}/config.h )
add_definitions( -DHAVE_CONFIG_H -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
# glob through source files/headers
file( GLOB WSRC_TOP *.cpp )
file( GLOB WSRC_CMDL commandline/*.cpp )
file( GLOB WSRC_SYS sys/*.cpp )
file( GLOB WSRC_LOG log/*.cpp )
file( GLOB WSRC_TEXT text/*.cpp )
file( GLOB WSRC_GRCAL grcal/*.cpp )
file( GLOB WSRC_STREAM stream/*.cpp )
file( GLOB WSRC_NET net/*.cpp )
file( GLOB H_TOP *.h )
file( GLOB H_CMDL commandline/*.h )
file( GLOB H_SYS sys/*.h )
file( GLOB H_LOG log/*.h )
file( GLOB H_TEXT text/*.h )
file( GLOB H_GRCAL grcal/*.h )
file( GLOB H_STREAM stream/*.h )
file( GLOB H_NET net/*.h )
file( GLOB H_TESTS tests/*.h )
file( GLOB TCC_TOP *.tcc )
file( GLOB testh *.test.h commandline/*.test.h sys/*.test.h
log/*.test.h text/*.test.h grcal/*.test.h stream/*.test.h net/*.test.h )
set( WSRC ${WSRC_TOP} ${WSRC_CMDL} ${WSRC_SYS} ${WSRC_LOG} ${WSRC_TEXT} ${WSRC_GRCAL} ${WSRC_STREAM} ${WSRC_NET})
# on some mingw32, regex.h is not on the default include path
find_path( RX_PATH regex.h )
if( RX_PATH )
include_directories( ${RX_PATH} )
endif()
# libwibble.a
if( NOT WIN32 )
set_source_files_properties( ${WSRC} COMPILE_FLAGS -fPIC )
endif( NOT WIN32 )
include_directories( ${wibble_SOURCE_DIR}/.. ${wibble_BINARY_DIR}/.. )
add_definitions( ${OPT_FLAGS} )
add_library( wibble STATIC ${WSRC} )
if( WIN32 )
target_link_libraries( wibble wsock32 psapi regex )
else( WIN32 )
target_link_libraries( wibble pthread )
endif( WIN32 )
# make check
wibble_add_test( wibble-test ${testh} )
target_link_libraries( wibble-test wibble )
wibble_check_target( wibble-test )
set( prefix "${CMAKE_INSTALL_PREFIX}" )
set( exec_prefix "${prefix}/bin" )
if (NOT DEFINED libdir)
set( libdir "${prefix}/lib" )
endif()
set( includedir "${prefix}/include" )
# cmake-time configuration
configure_file( ${wibble_SOURCE_DIR}/libwibble.pc.in
${wibble_BINARY_DIR}/libwibble.pc @ONLY )
# make install
install( TARGETS wibble DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE} COMPONENT wibble_dev )
if( NOT WIN32 )
install( FILES ${wibble_BINARY_DIR}/libwibble.pc DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig COMPONENT wibble_dev )
install( FILES libwibble.m4 DESTINATION share/aclocal COMPONENT wibble_dev )
install( FILES wibble-test-genrunner.1 DESTINATION share/man/man1 COMPONENT wibble_dev )
endif( NOT WIN32 )
install( FILES ${H_TOP} DESTINATION include/wibble COMPONENT wibble_dev )
install( FILES ${TCC_TOP} DESTINATION include/wibble COMPONENT wibble_dev )
install( FILES ${H_CMDL} DESTINATION include/wibble/commandline COMPONENT wibble_dev )
install( FILES ${H_SYS} DESTINATION include/wibble/sys COMPONENT wibble_dev )
install( FILES ${H_LOG} DESTINATION include/wibble/log COMPONENT wibble_dev )
install( FILES ${H_TEXT} DESTINATION include/wibble/text COMPONENT wibble_dev )
install( FILES ${H_GRCAL} DESTINATION include/wibble/grcal COMPONENT wibble_dev )
install( FILES ${H_STREAM} DESTINATION include/wibble/stream COMPONENT wibble_dev )
install( FILES ${H_NET} DESTINATION include/wibble/net COMPONENT wibble_dev )
install( FILES ${H_TESTS} DESTINATION include/wibble/tests COMPONENT wibble_dev )
if( NOT WIN32 )
install( FILES test.cmake DESTINATION share/wibble COMPONENT wibble_dev )
install( FILES test-genrunner.pl
RENAME wibble-test-genrunner
DESTINATION bin COMPONENT wibble_dev
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
endif( NOT WIN32 )
|