* All tools:

- Library linking: there must not be "target_link_library()" for libraries,
        only when building binaries. Avoid clashes between static module
        or class variables, and strange reinitialisation of those variables.
    - Change: Boost is now always linked staticly.
  * ./crlcore:
    - Change: In System, static initialisation problem again, there seems to
        be a race between it and boost::filesystem, make the singleton creation
        "at first call" again. Triggers the System singleton creation in
        AllianceFramework to spare the user the need to explicitly doing it.
    - New: In Utilities, automatically adds the "site-packages" PYTHONPATH
        component, guessed from CORIOLIS_TOP.
This commit is contained in:
Jean-Paul Chaput 2010-07-01 11:48:16 +00:00
parent fbd9aba2f5
commit f901abe0ad
7 changed files with 70 additions and 33 deletions

View File

@ -41,6 +41,9 @@ SET(QT_USE_QTXML "true")
LIST(INSERT CMAKE_MODULE_PATH 0 "${CRLCORE_SOURCE_DIR}/cmake_modules/")
FIND_PACKAGE(LibXml2 REQUIRED)
FIND_PACKAGE(PythonLibs REQUIRED)
FIND_PACKAGE(PythonSitePackages REQUIRED)
FIND_PACKAGE(Qt4 REQUIRED) # find and setup Qt4 for this project
FIND_PACKAGE(BISON REQUIRED)
FIND_PACKAGE(FLEX REQUIRED)
@ -51,7 +54,7 @@ FIND_PACKAGE(HURRICANE REQUIRED)
INCLUDE(UseLATEX)
SET_LIB_LINK_MODE()
FIND_PACKAGE(Boost 1.33.1 COMPONENTS program_options REQUIRED)
FIND_PACKAGE(Boost 1.33.1 COMPONENTS program_options filesystem REQUIRED)
STRING(REGEX MATCH "^/usr" IS_USR "$ENV{CORIOLIS_TOP}")
STRING(REGEX MATCH "^/opt" IS_OPT "$ENV{CORIOLIS_TOP}")

View File

@ -63,6 +63,9 @@ namespace CRL {
, _parentLibrary(NULL)
, _routingGauges()
{
// Triggers System singleton loading.
System::get ();
DataBase* db = DataBase::getDB ();
if ( !db )
db = DataBase::create ();

View File

@ -27,10 +27,12 @@
${HURRICANE_INCLUDE_DIR}
${CIF_INCLUDE_DIR}
${CONFIGURATION_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
)
add_definitions ( -DCORIOLIS_TOP="${CORIOLIS_TOP}"
-DSYS_CONF_DIR="${SYS_CONF_DIR}"
-DPYTHON_SITE_PACKAGES="${PYTHON_SITE_PACKAGES}"
)
set ( includes crlcore/Utilities.h
@ -239,14 +241,4 @@
${lefdef_cpps}
${openaccess_cpps}
)
target_link_libraries ( crlcore ${HURRICANE_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
${QT_LIBRARIES}
${IO_LIBRARIES}
${LEFDEF_LIBRARIES}
${OA_LIBRARIES}
${AGDS_LIBRARY}
${CIF_LIBRARY}
${CONFIGURATION_LIBRARY}
)
install ( TARGETS crlcore DESTINATION lib${LIB_SUFFIX} )

View File

@ -32,8 +32,9 @@
#include <boost/program_options.hpp>
namespace boptions = boost::program_options;
#include "hurricane/Warning.h"
#include "vlsisapd/configuration/Configuration.h"
#include "hurricane/Warning.h"
#include "hurricane/isobar/Script.h"
#include "crlcore/Utilities.h"
@ -199,12 +200,14 @@ namespace CRL {
// Class : "CRL::System".
System* System::_singleton = System::get();
System* System::_singleton = NULL; //System::get();
System::System ()
: _catchCore(true)
{
cerr << "Creating System singleton." << endl;
// Immediate setup to avoid some tiresome looping...
_singleton = this;
@ -223,17 +226,17 @@ namespace CRL {
// Environment variables reading.
boptions::options_description options ("Environment Variables");
options.add_options()
( "coriolis_top", boptions::value<string>()
( "coriolis_top", boptions::value<string>()->default_value(CORIOLIS_TOP)
, "The root directory of the Coriolis installation tree." );
boptions::variables_map arguments;
boptions::store ( boptions::parse_environment(options,environmentMapper), arguments );
boptions::notify ( arguments );
bfs::path::default_name_check ( bfs::portable_posix_name );
if ( bfs::path::default_name_check_writable() )
bfs::path::default_name_check ( bfs::portable_posix_name );
const string strSysConfDir = SYS_CONF_DIR;
bfs::path sysConfDir ( strSysConfDir );
bfs::path sysConfDir ( SYS_CONF_DIR );
if ( not sysConfDir.has_root_path() ) {
if ( arguments.count("coriolis_top") ) {
sysConfDir = arguments["coriolis_top"].as<string>() / sysConfDir;
@ -280,6 +283,11 @@ namespace CRL {
conf->readFromFile ( dotConfFile.string() );
}
bfs::path pythonSitePackages = PYTHON_SITE_PACKAGES;
pythonSitePackages = arguments["coriolis_top"].as<string>() / pythonSitePackages;
Isobar::Script::addPath ( pythonSitePackages.string() );
// Delayed printing, as we known only now whether VerboseLevel1 is requested.
if ( cmess1.enabled() ) {
cmess1 << " o Reading Configuration. " << endl;

View File

@ -20,11 +20,20 @@
add_executable ( cyclop ${cpps} ${MOCcpps} )
target_link_libraries ( cyclop crlcore
${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
${HURRICANE_LIBRARIES}
${CONFIGURATION_LIBRARY}
${AGDS_LIBRARY}
${CIF_LIBRARY}
${IO_LIBRARIES}
${OA_LIBRARIES}
${LEFDEF_LIBRARIES}
${QT_LIBRARIES}
${Boost_LIBRARIES} )
${Boost_LIBRARIES}
${LIBXML2_LIBRARIES}
${PYTHON_LIBRARIES}
-lutil
)
install ( TARGETS cyclop DESTINATION bin )

View File

@ -28,7 +28,10 @@
using namespace std;
#include <boost/program_options.hpp>
namespace poptions = boost::program_options;
namespace boptions = boost::program_options;
#include <boost/filesystem/operations.hpp>
namespace bfs = boost::filesystem;
#include <QtGui>
#if (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) and not defined (__APPLE__)
@ -93,35 +96,41 @@ namespace {
int main ( int argc, char *argv[] )
{
int returnCode = 0;
try {
bfs::path::default_name_check ( bfs::portable_posix_name );
unsigned int traceLevel;
bool verbose1;
bool verbose2;
bool coreDump;
bool textMode;
poptions::options_description options ("Command line arguments & options");
boptions::options_description options ("Command line arguments & options");
options.add_options()
( "help,h" , "Print this help." )
( "verbose,v" , poptions::bool_switch(&verbose1)->default_value(false)
( "verbose,v" , boptions::bool_switch(&verbose1)->default_value(false)
, "First level of verbosity.")
( "very-verbose,V", poptions::bool_switch(&verbose2)->default_value(false)
( "very-verbose,V", boptions::bool_switch(&verbose2)->default_value(false)
, "Second level of verbosity.")
( "core-dump,D" , poptions::bool_switch(&coreDump)->default_value(false)
( "core-dump,D" , boptions::bool_switch(&coreDump)->default_value(false)
, "Enable core dumping.")
( "text,t" , poptions::bool_switch(&textMode)->default_value(false)
( "text,t" , boptions::bool_switch(&textMode)->default_value(false)
, "Run in pure text mode.")
( "trace-level,l" , poptions::value<unsigned int>(&traceLevel)->default_value(1000)
( "trace-level,l" , boptions::value<unsigned int>(&traceLevel)->default_value(1000)
, "Set the level of trace, trace messages with a level superior to "
"<arg> will be printed on <stderr>." )
( "cell,c" , poptions::value<string>()
( "cell,c" , boptions::value<string>()
, "The name of the cell to load, whithout extension." );
poptions::variables_map arguments;
poptions::store ( poptions::parse_command_line(argc,argv,options), arguments );
poptions::notify ( arguments );
boptions::variables_map arguments;
boptions::store ( boptions::parse_command_line(argc,argv,options), arguments );
boptions::notify ( arguments );
bfs::path userConfFile = "ma/configuration";
cerr << "Mark:" << userConfFile.string() << endl;
if ( arguments.count("help") ) {
cout << options << endl;
@ -223,12 +232,16 @@ int main ( int argc, char *argv[] )
returnCode = qa->exec();
}
}
catch ( poptions::error& e ) {
catch ( Error& e ) {
cerr << e.what() << endl;
exit ( 1 );
}
catch ( boptions::error& e ) {
cerr << "[ERROR] " << e.what() << endl;
exit ( 1 );
}
catch ( Error& e ) {
cerr << e.what() << endl;
catch ( exception& e ) {
cerr << "[ERROR] " << e.what() << endl;
exit ( 1 );
}
catch ( ... ) {

View File

@ -11,9 +11,18 @@
add_executable ( cx2y ${cpps} )
target_link_libraries ( cx2y crlcore
${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
${HURRICANE_LIBRARIES}
${CONFIGURATION_LIBRARY}
${AGDS_LIBRARY}
${CIF_LIBRARY}
${OA_LIBRARIES}
${QT_LIBRARIES}
${Boost_LIBRARIES} )
${LEFDEF_LIBRARIES}
${Boost_LIBRARIES}
${LIBXML2_LIBRARIES}
${PYTHON_LIBRARIES}
-lutil
)
install ( TARGETS cx2y DESTINATION bin )