ENH: mark some vars as advanced (and resort the list)
[cmake.git] / Source / cmFLTKWrapUICommand.cxx
blob1ea9d8ebc539d4fc6fefb78f5f73b4b3b19493a5
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmFLTKWrapUICommand.cxx,v $
5 Language: C++
6 Date: $Date: 2002-09-15 13:54:08 $
7 Version: $Revision: 1.14 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmFLTKWrapUICommand.h"
19 // cmFLTKWrapUICommand
20 bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args)
22 if(args.size() != 2 )
24 this->SetError("called with incorrect number of arguments");
25 return false;
28 // Now check and see if the value has been stored in the cache
29 // already, if so use that value and don't look for the program
30 const char* FLTK_WRAP_UI_value = m_Makefile->GetDefinition("FLTK_WRAP_UI");
31 if (FLTK_WRAP_UI_value==0)
33 this->SetError("called with FLTK_WRAP_UI undefined");
34 return false;
37 if(cmSystemTools::IsOff(FLTK_WRAP_UI_value))
39 this->SetError("called with FLTK_WRAP_UI off : ");
40 return false;
44 // what is the current source dir
45 std::string cdir = m_Makefile->GetCurrentDirectory();
47 // get parameter for the command
48 m_Target = args[0]; // Target that will use the generated files
49 m_GUISourceList = args[1]; // Source List of the GUI source files
51 std::vector<std::string> newArgs;
52 m_Makefile->ExpandSourceListArguments(args,newArgs, 1);
54 // get the list of GUI files from which .cxx and .h will be generated
55 std::string outputDirectory = m_Makefile->GetCurrentOutputDirectory();
57 // Some of the generated files are *.h so the directory "GUI"
58 // where they are created have to be added to the include path
59 m_Makefile->AddIncludeDirectory( outputDirectory.c_str() );
61 for(std::vector<std::string>::iterator i = (newArgs.begin() + 1);
62 i != newArgs.end(); i++)
64 cmSourceFile *curr = m_Makefile->GetSource(i->c_str());
65 // if we should use the source GUI
66 // to generate .cxx and .h files
67 if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
69 cmSourceFile header_file;
70 cmSourceFile source_file;
71 std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*i);
72 const bool headerFileOnly = true;
73 header_file.SetName(srcName.c_str(),
74 outputDirectory.c_str(), "h",headerFileOnly);
75 source_file.SetName(srcName.c_str(),
76 outputDirectory.c_str(), "cxx",!headerFileOnly);
77 std::string origname = cdir + "/" + *i;
78 std::string hname = header_file.GetFullPath();
79 m_WrapUserInterface.push_back(origname);
80 // add starting depends
81 source_file.GetDepends().push_back(hname);
82 source_file.GetDepends().push_back(origname);
83 header_file.GetDepends().push_back(origname);
84 m_GeneratedHeadersClasses.push_back(header_file);
85 m_GeneratedSourcesClasses.push_back(source_file);
89 return true;
92 void cmFLTKWrapUICommand::FinalPass()
95 // first we add the rules for all the .fl to .h and .cxx files
96 size_t lastHeadersClass = m_GeneratedHeadersClasses.size();
97 std::string fluid_exe = "${FLTK_FLUID_EXECUTABLE}";
100 std::string outputGUIDirectory = m_Makefile->GetCurrentOutputDirectory();
102 // Generate code for all the .fl files
103 for(size_t classNum = 0; classNum < lastHeadersClass; classNum++)
105 // set up .fl to .h and .cxx command
106 std::string hres = outputGUIDirectory;
107 hres += "/";
108 hres += m_GeneratedHeadersClasses[classNum].GetSourceName() + "." +
109 m_GeneratedHeadersClasses[classNum].GetSourceExtension();
111 std::string cxxres = outputGUIDirectory;
112 cxxres += "/";
113 cxxres += m_GeneratedSourcesClasses[classNum].GetSourceName() + "." +
114 m_GeneratedSourcesClasses[classNum].GetSourceExtension();
116 std::vector<std::string> cxxargs;
117 cxxargs.push_back("-c"); // instructs Fluid to run in command line
118 cxxargs.push_back("-h"); // optionally rename .h files
119 cxxargs.push_back(hres);
120 cxxargs.push_back("-o"); // optionally rename .cxx files
121 cxxargs.push_back(cxxres);
122 cxxargs.push_back(m_WrapUserInterface[classNum]);// name of the GUI fluid file
124 std::vector<std::string> depends;
126 std::vector<std::string> outputs;
127 outputs.push_back( cxxres );
128 outputs.push_back( hres );
130 // Add command for generating the .h and .cxx files
131 m_Makefile->AddCustomCommand(m_WrapUserInterface[classNum].c_str(),
132 fluid_exe.c_str(), cxxargs, depends,
133 outputs, m_Target.c_str() );
134 cmSourceFile* sf = m_Makefile->AddSource(m_GeneratedSourcesClasses[classNum]);
136 m_Makefile->GetTargets()[m_Target].GetSourceFiles().push_back( sf );