1 cmake_minimum_required(VERSION 2.8)
5 set(CONF_PATH "conf" CACHE PATH "Configuration file path")
6 set(MODULE_PATH "modules" CACHE PATH "Module path")
7 set(DATA_PATH "data" CACHE PATH "Data path")
8 set(LOG_PATH "logs" CACHE PATH "Log file path")
10 set(EXTRA_INCLUDES "" CACHE PATH "Extra include paths")
11 set(EXTRA_LIBS "" CACHE PATH "Extra library paths")
13 set(INSPIRCD_BASE "${CMAKE_CURRENT_SOURCE_DIR}/../")
15 # Build with multiple processes
16 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
18 # Use our own NSIS template
19 set(CMAKE_MODULE_PATH "${INSPIRCD_BASE}/win")
21 # Grab version info from version.sh
22 file(STRINGS "${INSPIRCD_BASE}/src/version.sh" VERSIONSH)
23 string(REGEX REPLACE ".*InspIRCd-([0-9]*).*" "\\1" MAJOR_VERSION "${VERSIONSH}")
24 string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.([0-9]*).*" "\\1" MINOR_VERSION "${VERSIONSH}")
25 string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.[0-9]*\\.([0-9]*).*" "\\1" PATCH_VERSION "${VERSIONSH}")
26 set(FULL_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
29 # Without /SAFESEH:NO old libraries compiled with VS 2010 or older won't link correctly to VS2012 (eg, extra module libs)
30 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
31 set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
32 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
33 set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
34 set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
35 set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
36 set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
37 set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
38 set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
39 set(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
40 set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
41 set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
44 file(GLOB INSPIRCD_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
45 "${INSPIRCD_BASE}/win/inspircd_win32wrapper.cpp"
46 "${INSPIRCD_BASE}/win/win32service.cpp" "${INSPIRCD_BASE}/src/*.cpp"
47 "${INSPIRCD_BASE}/src/modes/*.cpp"
48 "${INSPIRCD_BASE}/src/socketengines/socketengine_select.cpp"
49 "${INSPIRCD_BASE}/src/threadengines/threadengine_win32.cpp")
50 list(SORT INSPIRCD_SOURCES)
52 include_directories("${INSPIRCD_BASE}/win" "${INSPIRCD_BASE}/include")
54 include_directories(${EXTRA_INCLUDES})
55 link_directories(${EXTRA_LIBS})
58 add_library(win32_memory STATIC "${INSPIRCD_BASE}/win/inspircd_memory_functions.cpp")
61 configure_file("${INSPIRCD_BASE}/win/inspircd.rc.cmake" "${INSPIRCD_BASE}/win/inspircd.rc")
62 configure_file("${INSPIRCD_BASE}/win/config.h.cmake" "${INSPIRCD_BASE}/win/config.h")
64 add_executable(inspircd ${INSPIRCD_SOURCES} "${INSPIRCD_BASE}/win/inspircd.rc")
65 target_link_libraries(inspircd win32_memory)
66 set_target_properties(inspircd PROPERTIES ENABLE_EXPORTS ON)
67 install(TARGETS inspircd DESTINATION .)
69 add_subdirectory(modules)
71 # Package any DLLs in win/
72 file(GLOB EXTRA_DLLS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${INSPIRCD_BASE}/win/*.dll")
73 install(FILES ${EXTRA_DLLS} DESTINATION .)
75 # Install example configs
76 file(GLOB_RECURSE EXAMPLE_CONFIGS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${INSPIRCD_BASE}/docs/conf/*.example")
77 install(FILES ${EXAMPLE_CONFIGS} DESTINATION conf)
79 # Create an empty data and logs directory and install them
80 file(MAKE_DIRECTORY ${DATA_PATH})
81 install(DIRECTORY ${DATA_PATH} DESTINATION .)
82 file(MAKE_DIRECTORY ${LOG_PATH})
83 install(DIRECTORY ${LOG_PATH} DESTINATION .)
85 if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
86 include(InstallRequiredSystemLibraries)
88 set(CPACK_PACKAGE_NAME "InspIRCd IRC Daemon")
89 set(CPACK_PACKAGE_VENDOR "InspIRCd Development Team")
90 set(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
91 set(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
92 set(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})
93 set(CPACK_PACKAGE_FILE_NAME "InspIRCd-${FULL_VERSION}")
94 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../docs/COPYING")
96 set(CPACK_GENERATOR "NSIS")
97 set(CPACK_PACKAGE_INSTALL_DIRECTORY "InspIRCd")
98 # NSIS has a bug with full nix paths, so this must contain at least one backslash
99 set(CPACK_PACKAGE_ICON "${INSPIRCD_BASE}/win\\\\inspircd.ico")
100 set(CPACK_NSIS_MUI_ICON "${INSPIRCD_BASE}/win\\\\inspircd.ico")
101 set(CPACK_NSIS_MUI_UNIICON "${INSPIRCD_BASE}/win\\\\inspircd.ico")
102 set(CPACK_NSIS_INSTALLED_ICON_NAME "inspircd.exe")
103 set(CPACK_NSIS_URL_INFO_ABOUT "http://www.inspircd.org/")
104 set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
107 endif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")