~townsend/compiz/fix-auto-vp-switch-0.9.10

« back to all changes in this revision

Viewing changes to cmake/CompizCommon.cmake

  • Committer: Sam Spilsbury
  • Date: 2012-10-16 13:53:20 UTC
  • mto: This revision was merged to the branch mainline in revision 3434.
  • Revision ID: sam.spilsbury@canonical.com-20121016135320-3zb8wy8u16eayb7m
Clean up the CMake code around the python modules and uninstalling
 - It isn't possible to build python extensions using distutils that
   link to things that we are building, because CMake provides no
   means for a custom command to depend on a library. Build them
   using CMake directly instead
 - Clean up the tests: the tests depended on having a working opengl
   and core plugin xml file and were also sensitive to xml data. Make
   a mock.xml and use that instead
 - Require ini for the compizconfig-python tests. They won't run without it
 - Fix the uninstall scripts. We were clobbering the uninstall target
   with the python uninstall targets, that is just plain wrong. Created
   a new cmake function to append custom uninstall scripts to the global
   uninstall script

Show diffs side-by-side

added added

removed removed

Lines of Context:
936
936
 
937
937
#### uninstall
938
938
 
 
939
function (compiz_add_code_to_uninstall_target CODE WORKING_DIRECTORY)
 
940
 
 
941
    set_property (GLOBAL
 
942
                  APPEND
 
943
                  PROPERTY COMPIZ_UNINSTALL_CODE_TARGETS
 
944
                  ${CODE})
 
945
 
 
946
    set_property (GLOBAL
 
947
                  APPEND
 
948
                  PROPERTY COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS
 
949
                  ${WORKING_DIRECTORY})
 
950
 
 
951
endfunction ()
 
952
 
939
953
macro (compiz_add_uninstall)
 
954
 
940
955
   if (NOT _compiz_uninstall_rule_created)
941
956
        compiz_set(_compiz_uninstall_rule_created TRUE)
942
957
 
943
958
        set (_file "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")
944
959
 
945
 
        file (WRITE  ${_file} "if (NOT EXISTS \"${CMAKE_BINARY_DIR}/install_manifest.txt\")\n")
 
960
        file (WRITE ${_file} "message (STATUS \"Uninstalling\")\n")
 
961
 
 
962
        get_property (COMPIZ_UNINSTALL_CODE_TARGETS_SET
 
963
                      GLOBAL
 
964
                      PROPERTY COMPIZ_UNINSTALL_CODE_TARGETS
 
965
                      SET)
 
966
 
 
967
        get_property (COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS_SET
 
968
                      GLOBAL
 
969
                      PROPERTY COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS
 
970
                      SET)
 
971
 
 
972
        if (COMPIZ_UNINSTALL_CODE_TARGETS_SET AND
 
973
            COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS_SET)
 
974
 
 
975
            get_property (COMPIZ_UNINSTALL_CODE_TARGETS
 
976
                          GLOBAL
 
977
                          PROPERTY COMPIZ_UNINSTALL_CODE_TARGETS)
 
978
 
 
979
            get_property (COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS
 
980
                          GLOBAL
 
981
                          PROPERTY COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS)
 
982
 
 
983
            list (LENGTH COMPIZ_UNINSTALL_CODE_TARGETS COMPIZ_UNINSTALL_CODE_TARGETS_LEN)
 
984
            math (EXPR COMPIZ_UNINSTALL_CODE_TARGETS_RANGE "${COMPIZ_UNINSTALL_CODE_TARGETS_LEN} - 1")
 
985
 
 
986
            foreach (ITER RANGE ${COMPIZ_UNINSTALL_CODE_TARGETS_RANGE})
 
987
 
 
988
                list (GET COMPIZ_UNINSTALL_CODE_TARGETS ${ITER} CODE_TARGET)
 
989
                list (GET COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS ${ITER} WORKING_DIRECTORY_TARGET)
 
990
 
 
991
                file (APPEND ${_file} "message (STATUS \"Executing custom uninstall script ${CODE_TARGET}\")\n")
 
992
                file (APPEND ${_file} "execute_process (COMMAND ${CODE_TARGET}\n")
 
993
                file (APPEND ${_file} "                 WORKING_DIRECTORY \"${WORKING_DIRECTORY_TARGET}\"\n")
 
994
                file (APPEND ${_file} "                 OUTPUT_VARIABLE cmd_output\n")
 
995
                file (APPEND ${_file} "                 RESULT_VARIABLE cmd_ret)\n")
 
996
                file (APPEND ${_file} "message (\"\${cmd_output}\")\n")
 
997
                file (APPEND ${_file} "if (NOT \"\${cmd_ret}\" STREQUAL 0)\n")
 
998
                file (APPEND ${_file} "    message (FATAL_ERROR \"Problem executing uninstall script ${CODE_TARGET} : \${cmd_ret}\")\n")
 
999
                file (APPEND ${_file} "endif (NOT \"\${cmd_ret}\" STREQUAL 0)\n")
 
1000
 
 
1001
            endforeach ()
 
1002
 
 
1003
        endif (COMPIZ_UNINSTALL_CODE_TARGETS_SET AND
 
1004
               COMPIZ_UNINSTALL_WORKING_DIRECTORY_TARGETS_SET)
 
1005
 
 
1006
        # Get the code that we need to uninstall, and write it out to the file
 
1007
 
 
1008
        file (APPEND ${_file} "if (NOT EXISTS \"${CMAKE_BINARY_DIR}/install_manifest.txt\")\n")
946
1009
        file (APPEND ${_file} "  message (FATAL_ERROR \"Cannot find install manifest: \\\"${CMAKE_BINARY_DIR}/install_manifest.txt\\\"\")\n")
947
1010
        file (APPEND ${_file} "endif (NOT EXISTS \"${CMAKE_BINARY_DIR}/install_manifest.txt\")\n\n")
948
1011
        file (APPEND ${_file} "file (READ \"${CMAKE_BINARY_DIR}/install_manifest.txt\" files)\n")