Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Build Fossil via ExternalProject |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | cmake-ide |
Files: | files | file ages | folders |
SHA3-256: |
cddc7bb0e4fe905deaf93d1a02220001 |
User & Date: | ashepilko 2018-08-02 09:24:14.211 |
Context
2018-08-02
| ||
09:37 | Allow reading the list of input resources from a file with --reslist option. ... (check-in: ba8ba160 user: ashepilko tags: cmake-ide) | |
09:24 | Build Fossil via ExternalProject ... (check-in: cddc7bb0 user: ashepilko tags: cmake-ide) | |
08:32 | Merge from trunk. ... (check-in: 19997e99 user: ashepilko tags: cmake-ide) | |
Changes
Changes to CMakeLists.txt.
|
| > > | > | < < < | < > | | | | | | > | < | < | > | > > > > > > > > > | > > > > | > > > > | < < | < > > > | | > | < > > > | > > > | | > > > > > > > > | < < < < < < < > > > | > > > | > > > | > > < | | | | | | > > | | > > > > | < > > > > > | | | | | | | | | | | < < | < < | > > > > > > > > > > | | > > > > | > > < > | > | > > | | < | > > > > > | > | > | | > | > > > > > > > > > > > | | > | > > > > | > > | < | | > | > | | < > > > > < < | > | | | > | < > > | < | < < | > > > | < < < | | < < < | < | | > > > > > > > | > > > > > > > > > > | | > | > | | > > > > > | < > | > > > > | | < < < < < < < < < < > > > > > > > | | | < < < < < | | < > | | < > > > > | > | | > > > > | > > > > > > | | | < > > > | > > | | > | > > | | > | | > > | < > | > > > | | | > > | < | < > > | > | > > | | < > | > | > | | < > > | > | > | 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(fossil C) include(ExternalProject) set(CMAKE_VERBOSE_MAKEFILE ON) set(default_build_type "RelWithDebInfo") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${default_build_type}' as none was specified.") set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") else() message(STATUS "'${CMAKE_BUILD_TYPE}' build type") endif() ## VARIABLES --------------------------------------------------------------- ## Additional parameters can be passed in the following variables which can ## be defined on cmake command line (or in cache). ## ## The parameters correspond to the ones used in the external fossil build ## process (as specified at configure, make, and make test) ## if(FOSSIL_CONFIGURE) message(STATUS "Fossil build configuration '${FOSSIL_CONFIGURE}'") set(configure_FLAGS ${FOSSIL_CONFIGURE}) endif() if(FOSSIL_BUILD) message(STATUS "Fossil build variables '${FOSSIL_BUILD}'") set(build_FLAGS ${FOSSIL_BUILD}) endif() if(FOSSIL_TEST) message(STATUS "Fossil test configuration '${FOSSIL_TEST}'") set(test_FLAGS ${FOSSIL_TEST}) endif() add_executable(fossil-exe IMPORTED) set(fossil_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(fossil_EXE_DIR "${fossil_INSTALL_DIR}/bin") set(fossil_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(fossil_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/fossil) if(MSVC) set(fossil_BUILD_DIR ${fossil_BINARY_DIR}/msvcbld) else(MSVC) set(fossil_BUILD_DIR ${fossil_BINARY_DIR}/bld) endif(MSVC) set(fossil_TEST_DIR "${fossil_BINARY_DIR}/test") set(EXE ${CMAKE_EXECUTABLE_SUFFIX}) set(fossil_EXE "${fossil_EXE_DIR}/fossil${EXE}") file(TO_NATIVE_PATH "${fossil_EXE}" fossil_EXE) set_target_properties(fossil-exe PROPERTIES IMPORTED_LOCATION "${fossil_EXE}" ) ## SETUP IDE --------------------------------------------------------------- ## Setup Project Sources View ## Add more source files for convenience; otherwise only actual dependencies ## would appear in the Projects tree pane. ## file(GLOB_RECURSE project_sources_DIRS #"autosetup/*" #may be useful when debuging configure "skins/*" "src/*" "test/*.test" "test/tester.tcl" "win/*" "www/*.wiki" "www/*.md" "www/*.html" ) file(GLOB project_sources_FILES "auto.def" "configure" "fossil.1" "manifest.uuid" "VERSION" "${fossil_BINARY_DIR}/autoconfig.h" "${fossil_BINARY_DIR}/Makefile*" "${fossil_BUILD_DIR}/*.[h]" #"${fossil_BUILD_DIR}/main_.c" ) include_directories( "${fossil_BUILD_DIR}" "${PROJECT_SOURCE_DIR}/src" "${PROJECT_SOURCE_DIR}" ) add_custom_target(project-sources ALL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} SOURCES ${project_sources_DIRS} ${project_sources_FILES} ) ## CONFIGURE --------------------------------------------------------------- ## set(fossil_configure_FLAGS "") if(configure_FLAGS) set(fossil_configure_FLAGS ${configure_FLAGS}) endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(MSVC) if(NOT "${fossil_configure_FLAGS}" MATCHES "FOSSIL_DEBUG") set(fossil_configure_FLAGS "FOSSIL_DEBUG=1" ${fossil_configure_FLAGS}) endif() else(MSVC) if(NOT "${fossil_configure_FLAGS}" MATCHES "--fossil-debug") set(fossil_configure_FLAGS "--fossil-debug" ${fossil_configure_FLAGS}) endif() endif(MSVC) endif() ## BUILD --------------------------------------------------------------- ## # Build fossil as an external project; just pass the options for configure and # build stages. This way we rely upon the existing build scripts. # # Install the resulting binary into the local binary dir, such that the fossil # binary can be located at the fixed location on target platform. # # Then we define CMake install targets to copy the binaries from the local # binary dir. # set(fossil_build_FLAGS "") if(build_FLAGS) set(fossil_build_FLAGS ${build_FLAGS}) endif() separate_arguments(fossil_configure_FLAGS) separate_arguments(fossil_build_FLAGS) if(MSVC) file(RELATIVE_PATH fossil_DESTDIR "${fossil_BINARY_DIR}" "${fossil_EXE_DIR}") file(TO_NATIVE_PATH "${fossil_DESTDIR}" fossil_DESTDIR) ExternalProject_Add(fossil PREFIX fossil SOURCE_DIR "${fossil_SOURCE_DIR}" CONFIGURE_COMMAND "" BINARY_DIR "${fossil_BINARY_DIR}" BUILD_COMMAND "${fossil_SOURCE_DIR}/win/buildmsvc.bat" all install ${fossil_configure_FLAGS} DESTDIR=${fossil_DESTDIR} ${fossil_build_FLAGS} VERBATIM INSTALL_COMMAND "" STEP_TARGETS configure build install ) else(MSVC) file(RELATIVE_PATH fossil_DESTDIR "${fossil_BINARY_DIR}" "${fossil_INSTALL_DIR}") ExternalProject_Add(fossil PREFIX fossil SOURCE_DIR "${fossil_SOURCE_DIR}" CONFIGURE_COMMAND "${fossil_SOURCE_DIR}/configure" --prefix=/ ${fossil_configure_FLAGS} VERBATIM BINARY_DIR "${fossil_BINARY_DIR}" BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" ${fossil_build_FLAGS} VERBATIM INSTALL_COMMAND "${CMAKE_MAKE_PROGRAM}" install DESTDIR=${fossil_DESTDIR} STEP_TARGETS configure build install ) endif(MSVC) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${fossil_BUILD_DIR}" "${fossil_EXE_DIR}" ) ExternalProject_Add_Step(fossil forcebuild COMMAND "${CMAKE_COMMAND}" -E echo "Build fossil" DEPENDEES configure DEPENDERS build ALWAYS 1 ) add_dependencies(fossil-exe fossil) ## We need an executable target, so that IDEs can infer what to run/debug. ## Define a substitute executable target to stand in for the actual fossil binary ## that we just built via ExternalProject_Add. ## Keep the actual fossil binary, clean up the built substitute artifacts. get_filename_component(app_NAME "${fossil_EXE}" NAME_WE) get_filename_component(app_DIR "${fossil_EXE}" DIRECTORY) file(TO_NATIVE_PATH "${app_DIR}" app_DIR) file(WRITE "${CMAKE_BINARY_DIR}/app.c" "int main(){ return 0; }\n") add_executable(app app.c) set_target_properties(app PROPERTIES OUTPUT_NAME "${app_NAME}" RUNTIME_OUTPUT_DIRECTORY "${app_DIR}" ) if(MSVC) set_target_properties(app PROPERTIES PDB_NAME "${app_NAME}" LINK_FLAGS "/INCREMENTAL:NO /MANIFEST:NO" ) endif() add_custom_command(TARGET app PRE_LINK COMMAND "${CMAKE_COMMAND}" -E chdir "$<TARGET_FILE_DIR:app>" "${CMAKE_COMMAND}" -E rename "$<TARGET_FILE_NAME:app>" "$<TARGET_FILE_NAME:app>-imported" ) if(MSVC) add_custom_command(TARGET app PRE_LINK COMMAND "${CMAKE_COMMAND}" -E chdir "$<TARGET_FILE_DIR:app>" "${CMAKE_COMMAND}" -E rename "$<TARGET_PROPERTY:app,PDB_NAME>.pdb" "$<TARGET_PROPERTY:app,PDB_NAME>.pdb-imported" ) endif() add_custom_command(TARGET app POST_BUILD COMMAND "${CMAKE_COMMAND}" -E chdir "$<TARGET_FILE_DIR:app>" "${CMAKE_COMMAND}" -E remove "$<TARGET_FILE_NAME:app>" COMMAND "${CMAKE_COMMAND}" -E chdir "$<TARGET_FILE_DIR:app>" "${CMAKE_COMMAND}" -E rename "$<TARGET_FILE_NAME:app>-imported" "$<TARGET_FILE_NAME:app>" ) if(MSVC) add_custom_command(TARGET app POST_BUILD COMMAND "${CMAKE_COMMAND}" -E chdir "$<TARGET_FILE_DIR:app>" "${CMAKE_COMMAND}" -E rename "$<TARGET_PROPERTY:app,PDB_NAME>.pdb-imported" "$<TARGET_PROPERTY:app,PDB_NAME>.pdb" ) endif(MSVC) add_dependencies(app fossil-exe) ## TEST --------------------------------------------------------------- ## add_custom_target(test-fossil-setup COMMENT "Setting up test-fossil" DEPENDS fossil-install ) add_custom_command(TARGET test-fossil-setup PRE_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory "${fossil_SOURCE_DIR}/test" "${fossil_TEST_DIR}" WORKING_DIRECTORY "${fossil_BINARY_DIR}" COMMENT "Copying data for test-fossil" VERBATIM ) add_custom_command(TARGET test-fossil-setup POST_BUILD COMMAND "${fossil_EXE}" new "${fossil_BINARY_DIR}/test-fossil.fsl" --admin-user testuser COMMAND "${fossil_EXE}" open "${fossil_BINARY_DIR}/test-fossil.fsl" COMMAND "${fossil_EXE}" user default testuser --user testuser WORKING_DIRECTORY "${fossil_TEST_DIR}" COMMENT "Setting up repository for test-fossil" VERBATIM ) # Run the test suite. # Other flags that can be included in TESTFLAGS are: # # -halt Stop testing after the first failed test # -keep Keep the temporary workspace for debugging # -prot Write a detailed log of the tests to the file ./prot # -verbose Include even more details in the output # -quiet Hide most output from the terminal # -strict Treat known bugs as failures # # TESTFLAGS can also include names of specific test files to limit # the run to just those test cases. set(TCL "tclsh") if( test_FLAGS ) set(fossil_test_FLAGS ${test_FLAGS}) endif() separate_arguments(fossil_test_FLAGS) add_custom_target(test-fossil COMMAND "${TCL}" tester.tcl "${fossil_EXE}" -quiet ${fossil_test_FLAGS} VERBATIM WORKING_DIRECTORY "${fossil_TEST_DIR}" COMMENT "Running test-fossil" DEPENDS fossil-install ) add_custom_target(test-fossil-clean COMMENT "Tearing down test-fossil" DEPENDS fossil-install ) add_custom_command(TARGET test-fossil-clean PRE_BUILD COMMAND "${CMAKE_COMMAND}" -E remove "${fossil_BINARY_DIR}/test-fossil.fsl" WORKING_DIRECTORY "${fossil_TEST_DIR}" COMMENT "Removing repository for test-fossil" VERBATIM ) add_custom_command(TARGET test-fossil-clean POST_BUILD COMMAND "${CMAKE_COMMAND}" -E remove_directory "${fossil_TEST_DIR}" WORKING_DIRECTORY "${fossil_BINARY_DIR}" COMMENT "Removing data for test-fossil" VERBATIM ) add_custom_target(clean-fossil COMMAND "${CMAKE_COMMAND}" -E remove_directory "${fossil_EXE_DIR}" VERBATIM COMMAND "${CMAKE_MAKE_PROGRAM}" clean VERBATIM WORKING_DIRECTORY "${fossil_BINARY_DIR}" COMMENT "Cleaning fossil build artifacts" DEPENDS fossil-configure ) enable_testing() add_test(NAME setup COMMAND "${CMAKE_COMMAND}" --build . --target test-fossil-setup ) add_test(NAME test COMMAND "${CMAKE_COMMAND}" --build . --target test-fossil ) add_test(NAME clean COMMAND "${CMAKE_COMMAND}" --build . --target test-fossil-clean ) set_property(TEST test APPEND PROPERTY DEPENDS setup) set_property(TEST clean APPEND PROPERTY DEPENDS setup) add_custom_target(check COMMAND "${CMAKE_CTEST_COMMAND}" -V DEPENDS test-fossil ) ## INSTALL --------------------------------------------------------------- ## install(DIRECTORY ${fossil_EXE_DIR}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/ USE_SOURCE_PERMISSIONS ) |