Esempio n. 1
0
    def __CreateCMakeSection_Rules(self):
        """ Create other rules in the CMakeLists.txt """
        for description, rule in self.project.rules.iteritems():
            self.file.write("\n#Adding rule %s\n" % description)
            command = "ADD_CUSTOM_COMMAND("
            command += "OUTPUT \"%s\"" % rule.output
            command += " COMMAND %s" % rule.command
            if len(rule.depends) > 0:
                command += " DEPENDS"
                for depend in rule.depends:
                    command += " %s" % depend
            command += " WORKING_DIRECTORY \"%s\"" % rule.workingDirectory
            command += " COMMENT \"Running rule %s\"" % description
            command += " VERBATIM"
            command += " )"
            self.file.write(command)

        # Adding specific windows macros
        if csnUtility.IsWindowsPlatform():
            self.file.write("\n#Adding specific windows macros\n")
            self.file.write(
                "INCLUDE( %s )\n" %
                "\"%s/cmakeMacros/PlatformDependent.cmake\"" %
                csnProject.globalCurrentContext.GetThirdPartyFolder(0))
            self.file.write("INCREASE_MSVC_HEAP_LIMIT( 1000 )\n")
            self.file.write("SUPPRESS_VC8_DEPRECATED_WARNINGS( )\n")
            self.file.write("SUPPRESS_LINKER_WARNING_4089( %s )\n" %
                            self.project.name)
            self.file.write("SUPPRESS_COMPILER_WARNING_DLL_EXPORT( %s )\n" %
                            self.project.name)
Esempio n. 2
0
    def testSearchProgramPath(self):
        if csnUtility.IsWindowsPlatform():
            # Hoping there is a cmake on the test machine
            # Default path for cmake
            refPath1 = r"C:\Program Files\CMake\bin\cmake.exe"
            path_end1 = r"\bin\cmake.exe"
            # typical windows XP key names for cmake
            key_names1 = []
            for i in range(0, 20):
                key_names1.append(
                    r"SOFTWARE\Wow6432Node\Kitware\CMake 2.8.%s" % i)
            key_names1.append(r"SOFTWARE\Wow6432Node\Kitware\CMake 2.8.12.1")
            key_names1.append(r"SOFTWARE\Wow6432Node\Kitware\CMake 2.8.12.2")
            key_names1.append(r"SOFTWARE\Wow6432Node\Kitware\CMake")
            value_names1 = [r""]
            resPath1 = csnUtility.SearchWindowsProgramPath(
                key_names1, value_names1, path_end1)
            self.assertEqual(resPath1, refPath1)

            # Wrong key name: should throw an exception
            key_names2 = [r"SOFTWARE\Wow6432Node\Kitware\CMake 8.7"]
            raisedError = False
            try:
                csnUtility.SearchWindowsProgramPath(key_names2, value_names1,
                                                    path_end1)
            except OSError:
                raisedError = True
            self.assertTrue(raisedError)

            # Wrong path
            value_names2 = [r"foo"]
            raisedError = False
            try:
                csnUtility.SearchWindowsProgramPath(key_names1, value_names2,
                                                    path_end1)
            except OSError:
                raisedError = True
            self.assertTrue(raisedError)

        else:
            # Search for "echo" command (is installed on almost every machine and it's easy to check, if it works)
            echoPath = csnUtility.SearchUnixProgramPath("echo")

            # check, if it works
            self.assertTrue(os.path.exists(echoPath))
            testString = "kjag3hjZaheiVRuhvi6ueahEvehr2avhjaeGjhgfj6aecuy3ge1uyAagfi"
            (status, echoOutput) = commands.getstatusoutput(
                '%s "%s"' % (echoPath, testString))
            self.assertEqual(status, 0)
            self.assertEqual(echoOutput, testString)

            # Wrong path
            raisedError = False
            try:
                csnUtility.SearchUnixProgramPath(
                    "somethingthatweforsuredontfind")
            except OSError:
                raisedError = True
            self.assertTrue(raisedError)
Esempio n. 3
0
 def __WriteDependencyCommands(self, dependencyProjects):
     self.file.write("\n")
     for dependencyProject in dependencyProjects:
         staticLibUsingAnotherLib = self.project.type == "library" and dependencyProject.type != "executable"
         noSources = (not isinstance(
             dependencyProject, csnProject.GenericProject)) or len(
                 dependencyProject.GetSources()) == 0
         if (csnUtility.IsWindowsPlatform()
                 and staticLibUsingAnotherLib) or noSources:
             continue
         else:
             self.file.write("ADD_DEPENDENCIES(%s %s)\n" %
                             (self.project.name, dependencyProject.name))
Esempio n. 4
0
 def __CreateCMakeSection_IncludeConfigAndUseFiles(self):
     """ Include the use file and config file for any dependency project, and finally also
     add the use and config file for this project (do this last, so that all definitions from
     the dependency projects are already included).
     """
     for project in self.project.dependenciesManager.ProjectsToUse():
         includeInSolution = project in self.project.dependenciesManager.projectsIncludedInSolution
         public = (self.project.name != project.name
                   and (not csnUtility.IsWindowsPlatform()
                        or not includeInSolution))
         self.file.write("INCLUDE(\"%s\")\n" %
                         (project.pathsManager.GetPathToConfigFile(public)))
         self.file.write("INCLUDE(\"%s\")\n" %
                         (project.pathsManager.GetPathToUseFile()))
Esempio n. 5
0
 def IsForPlatform(self, _WIN32, _NOT_WIN32):
     return ((
         (not csnUtility.IsWindowsPlatform()) and _NOT_WIN32)  # Unix match
             or (csnUtility.IsWindowsPlatform() and _WIN32)  # Cygwin match
             or (not _WIN32 and not _NOT_WIN32))  # Nothing demanded