From 465dabd9198b12bca076ca2f99c5d9298185b13d Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Mon, 16 Jul 2012 16:48:51 +0200 Subject: [PATCH] Fixes Win32 compilation that my previous commit broke, thanks to JP --- CMakeLists.txt | 25 ++++++++--- pcbnew/CMakeLists.txt | 44 +++++++++++-------- .../dialogs/dialog_footprint_wizard_list.cpp | 4 +- pcbnew/footprint_wizard.cpp | 3 ++ 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a518154595..952cdd9d95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,14 +91,25 @@ endif(KICAD_STABLE_VERSION ) #================================================ if(CMAKE_COMPILER_IS_GNUCXX) - # Set default flags for Release build. - set(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG -fPIC") - set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2 -DNDEBUG -fPIC") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s") + if(WIN32) # under Windows/mingw, -fPIC option is enabled by default + # Set default flags for Release build. + set(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2 -DNDEBUG") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s") - # Set default flags for Debug build. - set(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG -fPIC") - set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG -fPIC") + # Set default flags for Debug build. + set(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG") + else(WIN32) + # Set default flags for Release build. + set(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG -fPIC") + set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2 -DNDEBUG -fPIC") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s") + + # Set default flags for Debug build. + set(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG -fPIC") + set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG -fPIC") + endif(WIN32) endif(CMAKE_COMPILER_IS_GNUCXX) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 0d94c46b99..a180852ca7 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -5,10 +5,10 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) SET(PYTHON_DEST "lib/python${PYTHON_VERSION}/dist-packages" ) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting) FIND_PACKAGE(SWIG REQUIRED) - INCLUDE(${SWIG_USE_FILE}) + INCLUDE(${SWIG_USE_FILE}) FIND_PACKAGE(PythonLibs) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) - add_definitions(-DPCBNEW -DKICAD_SCRIPTING) + add_definitions(-DPCBNEW -DKICAD_SCRIPTING) endif() ### @@ -246,7 +246,7 @@ set(PCBNEW_SCRIPTING_DIALOGS ) -set(PCBNEW_SCRIPTING_PYTHON_HELPERS +set(PCBNEW_SCRIPTING_PYTHON_HELPERS ../scripting/wx_python_helpers.cpp ../scripting/python_scripting.cpp scripting/pcbnew_scripting_helpers.cpp @@ -268,16 +268,16 @@ endif() if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) set(SWIG_FLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/../.. -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}/../include -I${CMAKE_CURRENT_SOURCE_DIR}/../scripting ) - if (DEBUG) + if (DEBUG) set(SWIG_FLAGS ${SWIG_FLAGS} -DDEBUG) endif() - # collect CFLAGS , and pass them to swig later - + # collect CFLAGS , and pass them to swig later + get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS ) foreach( d ${DirDefs} ) SET(SWIG_FLAGS ${SWIG_FLAGS} -D${d} ) endforeach() - + # check if we have IO_MGR and KICAD_PLUGIN available if ( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE ) SET(SWIG_FLAGS ${SWIG_FLAGS} -DBUILD_WITH_PLUGIN) @@ -287,11 +287,11 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) endif() endif() - + if (KICAD_SCRIPTING) SET(SWIG_OPTS -python -c++ -outdir ${CMAKE_CURRENT_BINARY_DIR} ${SWIG_FLAGS} ) - + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx DEPENDS scripting/pcbnew.i @@ -304,13 +304,13 @@ if (KICAD_SCRIPTING) DEPENDS ../scripting/kicad.i DEPENDS ../scripting/wx.i DEPENDS ../scripting/kicadplugins.i - + COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) - + endif(KICAD_SCRIPTING) @@ -323,7 +323,7 @@ if (KICAD_SCRIPTING_MODULES) SET(CMAKE_SWIG_FLAGS ${SWIG_FLAGS}) SET_SOURCE_FILES_PROPERTIES(scripting/pcbnew.i PROPERTIES CPLUSPLUS ON) SWIG_ADD_MODULE(pcbnew python scripting/pcbnew.i ${PCBNEW_SCRIPTING_PYTHON_HELPERS} ${PCBNEW_SRCS} ${PCBNEW_COMMON_SRCS}) - SWIG_LINK_LIBRARIES(pcbnew + SWIG_LINK_LIBRARIES(pcbnew 3d-viewer pcbcommon common @@ -334,9 +334,14 @@ if (KICAD_SCRIPTING_MODULES) ${OPENGL_LIBRARIES} ${GDI_PLUS_LIBRARIES} ${PYTHON_LIBRARIES}) - + endif (KICAD_SCRIPTING_MODULES) +if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) + set ( PCBNEW_EXTRA_LIBS "rt" ) +endif (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) + + ### # Windows resource file ### @@ -410,6 +415,7 @@ endif(APPLE) ### # Link executable target pcbnew with correct libraries ### + target_link_libraries(pcbnew 3d-viewer pcbcommon @@ -421,7 +427,7 @@ target_link_libraries(pcbnew ${OPENGL_LIBRARIES} ${GDI_PLUS_LIBRARIES} ${PYTHON_LIBRARIES} - rt + ${PCBNEW_EXTRA_LIBS} ) ### @@ -435,7 +441,7 @@ if(KICAD_SCRIPTING) add_custom_target(FixSwigImportsScripting ALL ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew - COMMENT "Fixing swig_import_helper" + COMMENT "Fixing swig_import_helper" ) @@ -447,13 +453,13 @@ if (KICAD_SCRIPTING_MODULES) add_custom_target(FixSwigImportsModuleScripting ALL ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew - COMMENT "Fixing swig_import_helper" + COMMENT "Fixing swig_import_helper" ) install(FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py DESTINATION ${PYTHON_DEST}) - + install(FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so DESTINATION ${PYTHON_DEST}) endif(KICAD_SCRIPTING_MODULES) @@ -463,12 +469,12 @@ endif(KICAD_SCRIPTING_MODULES) if(NOT MSVC) # This one gets made only when testing. add_executable(specctra_test EXCLUDE_FROM_ALL specctra_test.cpp specctra.cpp) - target_link_libraries(specctra_test common ${wxWidgets_LIBRARIES} rt) + target_link_libraries(specctra_test common ${wxWidgets_LIBRARIES}) endif(NOT MSVC) # This one gets made only when testing. add_executable(layer_widget_test WIN32 EXCLUDE_FROM_ALL layer_widget.cpp ) -target_link_libraries(layer_widget_test common ${wxWidgets_LIBRARIES} rt) +target_link_libraries(layer_widget_test common ${wxWidgets_LIBRARIES}) diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index 53e8ab3c36..d517e8c1c9 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -1,8 +1,8 @@ /** - * @file dialog_scripting.cpp + * @file dialog_footprint_wizard_list.cpp */ -#include +#include diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp index 74c16f74b4..6509f61b26 100644 --- a/pcbnew/footprint_wizard.cpp +++ b/pcbnew/footprint_wizard.cpp @@ -87,6 +87,9 @@ void FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos() void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() { + if( m_FootprintWizard == NULL ) + return; + SetCurItem( NULL ); // Delete the current footprint GetBoard()->m_Modules.DeleteAll();