]> granicus.if.org Git - fortune-mod/blob - fortune-mod/datfiles/CMakeLists.txt
try2fix crosscompiling builds + cmake fixes
[fortune-mod] / fortune-mod / datfiles / CMakeLists.txt
1 # See: https://github.com/shlomif/fortune-mod/issues/58
2 if (IS_CROSS)
3     SET (_strfile  "strfile")
4     find_program(_found "${_strfile}")
5     if (NOT _found)
6         MESSAGE(FATAL_ERROR "\"strfile\" must be in the executables' path for cross-compiling builds. You can get it from a native install of fortune-mod: https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them . Also see https://github.com/shlomif/fortune-mod/issues/58 .")
7     endif()
8 else()
9     SET (_strfile  "${CMAKE_CURRENT_BINARY_DIR}/../strfile")
10 endif()
11 SET (_unrot_cookies )
12 SET (_install_unrot_cookies )
13 FOREACH(c ${COOKIES})
14     SET(DEST "${c}.dat")
15     SET(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/${c}")
16
17     SET(PATH_PERL ${PERL_EXECUTABLE})
18     ADD_CUSTOM_COMMAND(
19         OUTPUT "${c}"
20         COMMAND ${PATH_PERL}
21         ARGS "-e"
22         "my (\$src, \$dest) = @ARGV; use File::Copy; copy(\$src, \$dest);"
23         "${SOURCE}"
24         "${c}"
25         DEPENDS "${SOURCE}"
26         VERBATIM
27     )
28     ADD_CUSTOM_COMMAND(
29         OUTPUT "${DEST}"
30         COMMAND "${_strfile}"
31         ARGS "${SOURCE}" "${DEST}"
32         DEPENDS "${SOURCE}" "${_strfile}"
33     )
34
35     SET(LINK "${c}.u8")
36     if (WIN32)
37     ADD_CUSTOM_COMMAND(
38         OUTPUT "${LINK}"
39         COMMAND ${CMAKE_COMMAND} -E copy "${SOURCE}" "${LINK}"
40     )
41     else()
42     ADD_CUSTOM_COMMAND(
43         OUTPUT "${LINK}"
44         COMMAND "ln"
45         ARGS "-sf" "${c}" "${LINK}"
46     )
47     endif()
48
49     SET(_targets_on_build_stage_for_avoiding_broken_symlinks_which_regenerate "${c}")
50     LIST(APPEND _unrot_cookies ${_targets_on_build_stage_for_avoiding_broken_symlinks_which_regenerate} "${DEST}" "${LINK}")
51     LIST(APPEND _install_unrot_cookies "${c}" "${CMAKE_CURRENT_BINARY_DIR}/${DEST}" "${CMAKE_CURRENT_BINARY_DIR}/${LINK}")
52
53 ENDFOREACH()
54
55 ADD_CUSTOM_TARGET(
56     plain_cookies ALL
57     DEPENDS ${_unrot_cookies}
58 )
59 INSTALL(
60     FILES ${_install_unrot_cookies}
61     DESTINATION "${LOCALDIR}"
62 )
63
64 IF (NOT NO_OFFENSIVE)
65     ADD_SUBDIRECTORY("off")
66 ENDIF()