2018-05-22 23:20:41 +03:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2018-09-07 22:45:33 +03:00
|
|
|
# Creates wrapper scripts and installs them in the user's binaries directory, which is usually "/usr/local/bin".
|
|
|
|
# This is required because symlinks use the folder they are in as working directory.
|
|
|
|
macro(install_wrapper_script component target)
|
|
|
|
get_filename_component(file_name ${target} NAME)
|
2018-05-22 23:20:41 +03:00
|
|
|
|
2018-09-07 22:45:33 +03:00
|
|
|
file(WRITE ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "#!/bin/sh\n")
|
|
|
|
file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "${target} \"$@\"\n")
|
|
|
|
file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "exit $?\n")
|
2018-05-22 23:20:41 +03:00
|
|
|
|
2018-09-07 22:45:33 +03:00
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/tmp/script/${file_name}
|
2018-08-10 00:33:38 +03:00
|
|
|
COMPONENT ${component}
|
2018-09-07 22:45:33 +03:00
|
|
|
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
|
2018-05-22 23:20:41 +03:00
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
|
|
)
|
|
|
|
endmacro(install_wrapper_script)
|
|
|
|
|
2018-09-07 22:45:33 +03:00
|
|
|
macro(install_systemd_service component file_path binary_path)
|
|
|
|
get_filename_component(file_name ${file_path} NAME)
|
|
|
|
get_filename_component(binary_directory ${binary_path} DIRECTORY)
|
|
|
|
|
|
|
|
file(READ ${file_path} FILE_CONTENT)
|
|
|
|
string(REPLACE "[DIRECTORY]" ${binary_directory} FILE_CONTENT ${FILE_CONTENT})
|
|
|
|
string(REPLACE "[BINARY]" ${binary_path} FILE_CONTENT ${FILE_CONTENT})
|
|
|
|
file(WRITE ${CMAKE_SOURCE_DIR}/tmp/systemd/${file_name} ${FILE_CONTENT})
|
|
|
|
|
|
|
|
if(EXISTS "/lib/systemd/system")
|
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/tmp/systemd/${file_name}
|
|
|
|
COMPONENT ${component}
|
|
|
|
DESTINATION "/lib/systemd/system"
|
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endmacro(install_systemd_service)
|
|
|
|
|
2018-05-22 23:20:41 +03:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
add_definitions(-D_DEBUG -DDEBUG)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
add_definitions(-DNDEBUG -DVPN_SPEED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
add_definitions(-DCPU_64)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(-D_REENTRANT -DREENTRANT -D_THREAD_SAFE -D_THREADSAFE -DTHREAD_SAFE -DTHREADSAFE -D_FILE_OFFSET_BITS=64)
|
|
|
|
|
|
|
|
# Add /src to the include paths
|
|
|
|
include_directories(.)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
message(FATAL_ERROR "Windows compilation via CMake is currently not supported.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UNIX)
|
2018-07-26 07:44:19 +03:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char")
|
2018-05-22 23:20:41 +03:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
|
|
|
|
|
|
|
|
add_definitions(-DUNIX)
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
|
|
|
add_definitions(-DUNIX_LINUX)
|
2018-08-09 10:00:16 +03:00
|
|
|
if("$ENV{USE_MUSL}" STREQUAL "YES")
|
2018-08-08 17:02:20 +03:00
|
|
|
add_definitions(-DUNIX_LINUX_MUSL)
|
|
|
|
endif()
|
2018-05-22 23:20:41 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
2018-08-23 11:56:30 +03:00
|
|
|
add_definitions(-DUNIX_BSD -DBRIDGE_BPF)
|
2018-05-22 23:20:41 +03:00
|
|
|
include_directories(SYSTEM /usr/local/include)
|
|
|
|
link_directories(SYSTEM /usr/local/lib)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
2018-08-23 11:56:30 +03:00
|
|
|
add_definitions(-DUNIX_BSD -DUNIX_OPENBSD)
|
2018-05-22 23:20:41 +03:00
|
|
|
include_directories(SYSTEM /usr/local/include)
|
|
|
|
link_directories(SYSTEM /usr/local/lib)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
|
|
|
|
add_definitions(-DUNIX_SOLARIS -DNO_VLAN)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
2018-08-23 11:56:30 +03:00
|
|
|
add_definitions(-DUNIX_BSD -DUNIX_MACOS -DBRIDGE_PCAP)
|
2018-05-22 23:20:41 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-07-26 07:44:19 +03:00
|
|
|
# Cedar communication module
|
|
|
|
add_subdirectory(Cedar)
|
2018-05-22 23:20:41 +03:00
|
|
|
|
2018-07-26 07:44:19 +03:00
|
|
|
# Mayaqua kernel
|
|
|
|
add_subdirectory(Mayaqua)
|
|
|
|
|
|
|
|
# hamcorebuilder utility
|
|
|
|
add_subdirectory(hamcorebuilder)
|
2018-05-22 23:20:41 +03:00
|
|
|
|
2018-07-26 07:44:19 +03:00
|
|
|
# vpnserver
|
|
|
|
add_subdirectory(vpnserver)
|
2018-05-22 23:20:41 +03:00
|
|
|
|
2018-07-26 07:44:19 +03:00
|
|
|
# vpnclient
|
|
|
|
add_subdirectory(vpnclient)
|
|
|
|
|
|
|
|
# vpnbridge
|
|
|
|
add_subdirectory(vpnbridge)
|
|
|
|
|
|
|
|
# vpncmd
|
|
|
|
add_subdirectory(vpncmd)
|
2018-05-22 23:20:41 +03:00
|
|
|
|
2018-10-08 06:10:54 +03:00
|
|
|
# vpntest
|
|
|
|
add_subdirectory(vpntest)
|
|
|
|
|
2018-05-22 23:20:41 +03:00
|
|
|
# hamcore.se2 archive file
|
|
|
|
add_custom_target(hamcore-archive-build
|
|
|
|
ALL
|
2018-10-18 03:02:17 +03:00
|
|
|
COMMAND hamcorebuilder "${CMAKE_SOURCE_DIR}/src/bin/hamcore/" "${BUILD_DIRECTORY}/hamcore.se2"
|
2018-05-22 23:20:41 +03:00
|
|
|
DEPENDS hamcorebuilder
|
|
|
|
COMMENT "Building hamcore.se2 archive file..."
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
|
|
|
# Print message after installing the targets
|
|
|
|
install(CODE "message(\"\n----------------------------------------------------------------------------------------------------------------------------\")")
|
|
|
|
install(CODE "message(\"Build completed successfully.\n\")")
|
|
|
|
install(CODE "message(\"Execute 'vpnserver start' to run the SoftEther VPN Server background service.\")")
|
|
|
|
install(CODE "message(\"Execute 'vpnbridge start' to run the SoftEther VPN Bridge background service.\")")
|
|
|
|
install(CODE "message(\"Execute 'vpnclient start' to run the SoftEther VPN Client background service.\")")
|
|
|
|
install(CODE "message(\"Execute 'vpncmd' to run the SoftEther VPN Command-Line Utility to configure VPN Server, VPN Bridge or VPN Client.\")")
|
|
|
|
install(CODE "message(\"----------------------------------------------------------------------------------------------------------------------------\n\")")
|