diff --git a/CMakeLists.txt b/CMakeLists.txt index 6691181..88f641a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,12 +15,15 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # Build output checks OPTION(LIBTINS_BUILD_SHARED "Build libtins as a shared library." ON) IF(LIBTINS_BUILD_SHARED) - MESSAGE(STATUS "Build will generate a shared library.") - MESSAGE(STATUS "Use LIBTINS_BUILD_SHARED=0 to perform a static build") - SET(LIBTINS_TYPE SHARED) + MESSAGE( + STATUS + "Build will generate a shared library. " + "Use LIBTINS_BUILD_SHARED=0 to perform a static build" + ) + SET(LIBTINS_TYPE SHARED) ELSE(LIBTINS_BUILD_SHARED) - MESSAGE(STATUS "Build will generate a static library.") - SET(LIBTINS_TYPE STATIC) + MESSAGE(STATUS "Build will generate a static library.") + SET(LIBTINS_TYPE STATIC) ENDIF(LIBTINS_BUILD_SHARED) # The version number. @@ -45,7 +48,11 @@ IF(LIBTINS_ENABLE_CXX11) MESSAGE(FATAL_ERROR "C++11 features requested but the compiler does not support them.") ENDIF(CXX11_COMPILER_FLAGS AND HAS_CXX11_NULLPTR AND HAS_CXX11_RVALUE_REFERENCES) ELSE(LIBTINS_ENABLE_CXX11) - MESSAGE(STATUS "Disabling C++11 features. Use LIBTINS_ENABLE_CXX11=1 to enable them.") + MESSAGE( + WARNING + "Disabling C++11 features. Use LIBTINS_ENABLE_CXX11=1 to enable them. " + "If your compiler is fairly new, you should enable this option, as it " + "increases the library performance") ENDIF(LIBTINS_ENABLE_CXX11) OPTION(LIBTINS_ENABLE_DOT11 "Compile libtins with IEEE 802.11 support" ON) @@ -75,28 +82,41 @@ ENABLE_TESTING() ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(tests) +ADD_SUBDIRECTORY(examples) # Add all targets to the build-tree export set -EXPORT(TARGETS tins - FILE "${PROJECT_BINARY_DIR}/libtinsTargets.cmake") +EXPORT( + TARGETS tins + FILE "${PROJECT_BINARY_DIR}/libtinsTargets.cmake" +) # Export the package for use from the build-tree # (this registers the build-tree with a global CMake-registry) EXPORT(PACKAGE libtins) + # Create the libtinsConfig.cmake and libtinsConfigVersion.cmake files # for the build tree SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include") -CONFIGURE_FILE(libtinsConfig.cmake.in - "${PROJECT_BINARY_DIR}/libtinsConfig.cmake" @ONLY) -CONFIGURE_FILE(libtinsConfigVersion.cmake.in - "${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake" @ONLY) +CONFIGURE_FILE( + libtinsConfig.cmake.in + "${PROJECT_BINARY_DIR}/libtinsConfig.cmake" @ONLY +) +CONFIGURE_FILE( + libtinsConfigVersion.cmake.in + "${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake" @ONLY +) # Install the libtinsConfig.cmake and libtinsConfigVersion.cmake -INSTALL(FILES - "${PROJECT_BINARY_DIR}/libtinsConfig.cmake" - "${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake" - DESTINATION CMake - COMPONENT dev) +INSTALL( + FILES + "${PROJECT_BINARY_DIR}/libtinsConfig.cmake" + "${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake" + DESTINATION CMake + COMPONENT dev +) + # Install the export set for use with the install-tree -INSTALL(EXPORT libtinsTargets - DESTINATION CMake - COMPONENT dev) +INSTALL( + EXPORT libtinsTargets + DESTINATION CMake + COMPONENT dev +) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..8d2cca1 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,49 @@ +FIND_PACKAGE(libtins QUIET) + +IF(libtins_FOUND) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples) + INCLUDE_DIRECTORIES(${LIBTINS_INCLUDE_DIRS}) + LINK_LIBRARIES(${LIBTINS_LIBRARIES}) + + IF(HAVE_CXX11) + SET(LIBTINS_CXX11_EXAMPLES + arpmonitor + dns_queries + dns_spoof + dns_stats + wps_detect + ) + ELSE(HAVE_CXX11) + MESSAGE(WARNING "Disabling some examples since C++11 support is disabled.") + ENDIF(HAVE_CXX11) + + ADD_CUSTOM_TARGET( + examples DEPENDS + arpspoofing + ${LIBTINS_CXX11_EXAMPLES} + beacon_display + portscan + traceroute + ) + + ADD_EXECUTABLE(arpspoofing EXCLUDE_FROM_ALL arpspoofing.cpp) + IF(HAVE_CXX11) + ADD_EXECUTABLE(arpmonitor EXCLUDE_FROM_ALL arpmonitor.cpp) + ADD_EXECUTABLE(dns_queries EXCLUDE_FROM_ALL dns_queries.cpp) + ADD_EXECUTABLE(dns_spoof EXCLUDE_FROM_ALL dns_spoof.cpp) + ADD_EXECUTABLE(dns_stats EXCLUDE_FROM_ALL dns_stats.cpp) + ADD_EXECUTABLE(wps_detect EXCLUDE_FROM_ALL wps_detect.cpp) + ENDIF(HAVE_CXX11) + + ADD_EXECUTABLE(beacon_display EXCLUDE_FROM_ALL beacon_display.cpp) + ADD_EXECUTABLE(portscan EXCLUDE_FROM_ALL portscan.cpp) + ADD_EXECUTABLE(traceroute EXCLUDE_FROM_ALL traceroute.cpp) + + TARGET_LINK_LIBRARIES(portscan pthread) +ELSE(libtins_FOUND) + MESSAGE( + WARNING + "Disabling examples since libtins is not installed. " + "Run cmake again once it is installed in order to compile them." + ) +ENDIF(libtins_FOUND) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6d016ec..0b7b64c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,5 +2,5 @@ FIND_PACKAGE(GTest) IF(GTEST_FOUND) ADD_SUBDIRECTORY(src) ELSE(GTEST_FOUND) - MESSAGE(STATUS "Google test not found. Disabling tests.") + MESSAGE(WARNING "Google test not found. Disabling tests.") ENDIF(GTEST_FOUND)