tangentia

CMakeLists - modsecurity-v2.9.12.txt

Jan 14th, 2026 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 5.71 KB | None | 0 0
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements.  See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License.  You may obtain a copy of the License at
  7. #
  8. #     http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
  17.  
  18. PROJECT(mod_security2 C)
  19.  
  20. IF(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/lib/libhttpd.lib)
  21.   MESSAGE(FATAL_ERROR "libhttpd.lib was not found in prefix ${CMAKE_INSTALL_PREFIX}")
  22. ENDIF()
  23.  
  24. # Select APR trunk (libapr-2.lib) if it exists in PREFIX/lib; otherwise, select
  25. # APR 1.x + APR-util 1.x
  26. #
  27. IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libapr-2.lib")
  28.   SET(apr_libraries
  29.     ${CMAKE_INSTALL_PREFIX}/lib/libapr-2.lib)
  30. ELSEIF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libapr-1.lib")
  31.   SET(apr_libraries
  32.     ${CMAKE_INSTALL_PREFIX}/lib/libapr-1.lib
  33.     ${CMAKE_INSTALL_PREFIX}/lib/libaprutil-1.lib)
  34. ELSE()
  35.   MESSAGE(FATAL_ERROR "APR libraries were not found in prefix ${CMAKE_INSTALL_PREFIX}")
  36. ENDIF()
  37.  
  38. IF(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/pcre2-8.lib)
  39.   SET(pcre_libraries
  40.     ${CMAKE_INSTALL_PREFIX}/lib/pcre2-8.lib)
  41. ELSE()
  42.   MESSAGE(FATAL_ERROR "pcre2-8.lib was not found in prefix ${CMAKE_INSTALL_PREFIX}")
  43. ENDIF()
  44.  
  45. IF(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/libxml2.lib)
  46.   SET(xml2_libraries
  47.     ${CMAKE_INSTALL_PREFIX}/lib/libxml2.lib)
  48. ELSE()
  49.   MESSAGE(FATAL_ERROR "libxml2.lib was not found in prefix ${CMAKE_INSTALL_PREFIX}")
  50. ENDIF()
  51.  
  52. IF(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/lua55.lib)
  53.   SET(lua_libraries
  54.     ${CMAKE_INSTALL_PREFIX}/lib/lua55.lib)
  55. ELSEIF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/lua54.lib")
  56.   SET(lua_libraries
  57.     ${CMAKE_INSTALL_PREFIX}/lib/lua54.lib)
  58. ELSE()
  59. MESSAGE(FATAL_ERROR "LUA libraries were not found in prefix ${CMAKE_INSTALL_PREFIX}")
  60. ENDIF()
  61.  
  62. IF(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/libcurl_imp.lib)
  63.   SET(curl_libraries
  64.     ${CMAKE_INSTALL_PREFIX}/lib/libcurl_imp.lib)
  65. ELSE()
  66.   MESSAGE(FATAL_ERROR "libcurl_imp.lib was not found in prefix ${CMAKE_INSTALL_PREFIX}")
  67. ENDIF()
  68.  
  69. IF(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/yajl.lib)
  70.   SET(yajl_libraries
  71.     ${CMAKE_INSTALL_PREFIX}/lib/yajl.lib)
  72. ELSE()
  73.   MESSAGE(FATAL_ERROR "yajl.lib was not found in prefix ${CMAKE_INSTALL_PREFIX}")
  74. ENDIF()
  75.  
  76. # Extra libraries.
  77. #
  78. SET(extra_libraries ws2_32.lib iphlpapi.lib)
  79.  
  80. # Miscellaneous options.
  81. #
  82. OPTION(INSTALL_PDB "Install .pdb file (if generated)" OFF)
  83.  
  84. SET(mod_security2_sources
  85.     apache2/mod_security2.c
  86.     apache2/apache2_config.c
  87.     apache2/apache2_io.c
  88.     apache2/apache2_util.c
  89.     apache2/re.c
  90.     apache2/re_operators.c
  91.     apache2/re_actions.c
  92.     apache2/re_tfns.c
  93.     apache2/re_variables.c
  94.     apache2/msc_logging.c
  95.     apache2/msc_xml.c
  96.     apache2/msc_multipart.c
  97.     apache2/modsecurity.c
  98.     apache2/msc_parsers.c
  99.     apache2/msc_util.c
  100.     apache2/msc_pcre.c
  101.     apache2/persist_dbm.c
  102.     apache2/msc_reqbody.c
  103.     apache2/msc_geo.c
  104.     apache2/msc_gsb.c
  105.     apache2/msc_crypt.c
  106.     apache2/msc_tree.c
  107.     apache2/msc_unicode.c
  108.     apache2/acmp.c
  109.     apache2/msc_lua.c
  110.     apache2/msc_release.c
  111.     apache2/msc_status_engine.c
  112.     apache2/msc_remote_rules.c
  113.     apache2/msc_json.c
  114.     apache2/libinjection/libinjection_html5.c
  115.     apache2/libinjection/libinjection_sqli.c
  116.     apache2/libinjection/libinjection_xss.c
  117. )
  118.  
  119. SET(mlogc_sources
  120.     mlogc/mlogc.c
  121. )
  122.  
  123. INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/include
  124.   ${CMAKE_INSTALL_PREFIX}/include/libxml2
  125.   ${CMAKE_SOURCE_DIR}/apache2
  126. )
  127.  
  128. ADD_LIBRARY(mod_security2 SHARED ${mod_security2_sources})
  129.  
  130. ADD_EXECUTABLE(mlogc ${mlogc_sources})
  131.  
  132. # Configure mlogc file substituting PERL macro in target file as we go.
  133. #
  134. set(PERL "perl")
  135. CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/mlogc/mlogc-batch-load.pl.in
  136.   mlogc-batch-load.pl @ONLY
  137. )
  138.  
  139. # Define extra macros to pass to C compiler.
  140. #
  141. ADD_DEFINITIONS(-DWITH_PCRE_JIT -DWITH_PCRE_STUDY -DWITH_PCRE2
  142.   -DWITH_LUA -DWITH_CURL -DWITH_REMOTE_RULES -DWITH_YAJL)
  143.  
  144. SET_TARGET_PROPERTIES(mod_security2 PROPERTIES SUFFIX .so)
  145. TARGET_LINK_LIBRARIES(mod_security2 ${CMAKE_INSTALL_PREFIX}/lib/libhttpd.lib
  146.   ${apr_libraries} ${pcre_libraries} ${xml2_libraries} ${lua_libraries}
  147.   ${curl_libraries} ${yajl_libraries} ${extra_libraries})
  148.  
  149. TARGET_LINK_LIBRARIES(mlogc ${apr_libraries} ${pcre_libraries} ${curl_libraries}
  150.   ${extra_libraries})
  151.  
  152. INSTALL(TARGETS mod_security2 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/modules)
  153.  
  154. INSTALL(TARGETS mlogc RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
  155.  
  156. INSTALL(FILES ${CMAKE_BINARY_DIR}/mod_security2.exp ${CMAKE_BINARY_DIR}/mod_security2.lib
  157.   DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
  158.  
  159. # Install extra configuration support files, if present.
  160. #
  161. INSTALL(FILES modsecurity.conf-recommended unicode.mapping
  162.   OPTIONAL DESTINATION ${CMAKE_INSTALL_PREFIX}/conf/extra)
  163.  
  164. INSTALL(FILES ${CMAKE_SOURCE_DIR}/mlogc/mlogc-default.conf
  165.   OPTIONAL DESTINATION ${CMAKE_INSTALL_PREFIX}/conf)
  166.  
  167. INSTALL(FILES ${CMAKE_BINARY_DIR}/mlogc-batch-load.pl
  168.   OPTIONAL DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
  169.  
  170. IF(INSTALL_PDB)
  171.   INSTALL(FILES ${CMAKE_BINARY_DIR}/mod_security2.pdb DESTINATION modules
  172.     CONFIGURATIONS RelWithDebInfo Debug)
  173.  
  174.   INSTALL(FILES ${CMAKE_BINARY_DIR}/mlogc.pdb DESTINATION bin
  175.     CONFIGURATIONS RelWithDebInfo Debug)
  176. ENDIF()
  177.  
Tags: cmake
Add Comment
Please, Sign In to add comment