Re: [CMake] Not sure how to list C# files in the generated Visual Studio project

2011-10-03 Thread David Cole
On Mon, Oct 3, 2011 at 10:22 AM, David Cole david.c...@kitware.com wrote:

 On Sat, Oct 1, 2011 at 4:08 PM, Stephen Torri stephen.to...@gmail.comwrote:

 On Sat, 2011-10-01 at 13:50 -0400, David Cole wrote:
  On Mon, Sep 26, 2011 at 11:37 AM, Stephen Torri
  stephen.to...@gmail.com wrote:
  I am using CMake to run SWIG to generate C# wrapper files for
  a
  project. While the attached CMakeLists.txt file produces a
  Visual
  Studio solutions that builds the C++ library, C# wrapper
  library and
  C# prototype executable I don't know first if I am using CMake
  correctly in this case.
 
  If it works, then it is not incorrect. :-)
 
  add_custom_command is the right way to build C# files driven by a
  CMakeLists.txt file at present.
 
  We've had feature requests before to add better C# support, but no
  serious funders to back a full implementation of generating *.csproj
  files for C# libs and executables. See this bug report (and related
  ones) for more info, specifically, this bug note:
  http://public.kitware.com/Bug/view.php?id=7918#c22170

 David,

 I think I am just going to generate the files for now and build a
 separate C# project in Visual Studio by hand. The reason for doing that
 is I am trying to make it easy to maintain this project. I figure I can
 do it by hand for now and make it easy to read.

 Your point about having this feature request before makes me wonder.
 What does it take to implement support for a new language?


 Please keep the discussion on-list, so others may also participate in the
 discussion. (thx)

 Support for a new language is not terribly difficult to implement, provided
 it has a compilation model similar to C/C++, and there is support for the
 language in all of the back-end build systems that CMake targets. It's quite
 easy actually, with the Makefile generators, to support C# even as a full
 featured CMake-supported language.

 But it is non-trivial to support Visual Studio C# *.csproj project files
 such that they'll work like Visual Studio C# developers are accustomed to.
 Hence my comments in the bug reports...


 Taking C#
 sharp as an example what parts of CMake does someone have to implement?


 C# related language module files, as documented in Chapter 11 of Mastering
 CMake. Specifically section 11.4, Adding a New Language.

 And *.csproj file generation support in many (all except for v6?) of the
 Visual Studio generator classes.


 HTH,
 David


--
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Not sure how to list C# files in the generated Visual Studio project

2011-10-01 Thread David Cole
On Mon, Sep 26, 2011 at 11:37 AM, Stephen Torri stephen.to...@gmail.comwrote:

 I am using CMake to run SWIG to generate C# wrapper files for a
 project. While the attached CMakeLists.txt file produces a Visual
 Studio solutions that builds the C++ library, C# wrapper library and
 C# prototype executable I don't know first if I am using CMake
 correctly in this case.


If it works, then it is not incorrect. :-)

add_custom_command is the right way to build C# files driven by a
CMakeLists.txt file at present.

We've had feature requests before to add better C# support, but no serious
funders to back a full implementation of generating *.csproj files for C#
libs and executables. See this bug report (and related ones) for more info,
specifically, this bug note:
http://public.kitware.com/Bug/view.php?id=7918#c22170


Secondly I am not sure what to do to list the
 C# files in the visual studio project so that I can quickly go to a
 the definition of a C# type for example. I would appreciate any
 feedback on how to improve the CMakeLists.txt file.


You probably should not try to list the *.cs files in a *.vcproj file... Not
sure what Visual Studio will do with such a condition. But you can try:
simply add the *.cs files as SOURCES for the custom target and they should
show up. If VS tries to compile them when you do that, in addition to the
custom build rules you're already specifying, then we may have to find a way
to avoid that... Give it a shot and let us know.

See the documentation on SOURCES in the add_custom_target help:

http://cmake.org/cmake/help/cmake-2-8-docs.html#command:add_custom_target


HTH,
David C.
--
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Not sure how to list C# files in the generated Visual Studio project

2011-09-26 Thread Stephen Torri
I am using CMake to run SWIG to generate C# wrapper files for a
project. While the attached CMakeLists.txt file produces a Visual
Studio solutions that builds the C++ library, C# wrapper library and
C# prototype executable I don't know first if I am using CMake
correctly in this case. Secondly I am not sure what to do to list the
C# files in the visual studio project so that I can quickly go to a
the definition of a C# type for example. I would appreciate any
feedback on how to improve the CMakeLists.txt file.

Stephen
cmake_minimum_required ( VERSION 2.6 )

# user section
PROJECT(MyProject)

#-
# FIND PACKAGES
#-
SET(MYPROJECT_MAJOR_VERSION 0)
SET(MYPROJECT_MINOR_VERSION 1)
SET(MYPROJECT_BUILD_VERSION 0)
SET(MYPROJECT_VERSION

${MYPROJECT_MAJOR_VERSION}.${MYPROJECT_MINOR_VERSION}.${MYPROJECT_BUILD_VERSION})
SET(MYPROJECT_API_VERSION
${MYPROJECT_MAJOR_VERSION}.${MYPROJECT_MINOR_VERSION})
SET(MYPROJECT_LIBRARY_PROPERTIES ${MYPROJECT_LIBRARY_PROPERTIES}
 VERSION ${MYPROJECT_VERSION}
 SOVERSION ${MYPROJECT_API_VERSION})

#-
# FIND PACKAGES
#-
SET(MyProject_CMAKE_DIR ${MyProject_SOURCE_DIR}/CMake CACHE INTERNAL )
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MyProject_CMAKE_DIR})

IF(WIN32)
   SET(Boost_USE_STATIC_LIBS ON)
   SET(Boost_USE_MULTITHREADED ON)
   SET(Boost_USE_STATIC_RUNTIME OFF)
ENDIF(WIN32)

SET(BOOST_ROOT C:/boost CACHE PATH Top directory of boost installation)
FIND_PACKAGE(Boost 1.45)

#-
# SHARED / STATIC
#-

# Allow the developer to select if Dynamic or Static libraries are built
OPTION(BUILD_SHARED_LIBS Build shared libraries. OFF)

# Set the LIB_TYPE variable to STATIC
SET (LIB_TYPE STATIC)
IF (BUILD_SHARED_LIBS)
  # User wants to build Dynamic Libraries, so change the LIB_TYPE variable to 
CMake keyword 'SHARED'
  SET (LIB_TYPE SHARED)
  IF(WIN32)
SET (BUILD_SHARED_WIN32 1)
  ENDIF(WIN32)
ENDIF (BUILD_SHARED_LIBS)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in 
${CMAKE_CURRENT_SOURCE_DIR}/config.hpp)

#-
#   FILES
#-
SET ( HEADERS
  MyProject_Interface.hpp
  Julian.hpp
  Longitude.hpp
  Latitude.hpp
  Terrain_Resolution.hpp )

SET (SOURCE
  MyProject_Interface.cpp )

#-
#   BUILD
#-
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} )

add_library ( MyProject ${SOURCE} ${HEADERS} )

target_link_libraries ( MyProject ${Boost_LIBRARIES} )

#-
#   SWIG
#-
IF (BUILD_SHARED_LIBS)
FIND_PACKAGE(SWIG REQUIRED)
MARK_AS_ADVANCED ( SWIG_DIR SWIG_EXECUTABLE SWIG_VERSION )
INCLUDE(${SWIG_USE_FILE})

FIND_PACKAGE(CSharp REQUIRED)
INCLUDE(${CSharp_USE_FILE})
 
# Configuration
#---
SET_SOURCE_FILES_PROPERTIES(SWIG_MyProject_Interface.i PROPERTIES 
CPLUSPLUS ON)

SET ( CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR} )

SET ( CMAKE_SWIG_FLAGS -namespace MyProject -dllimport 
MyProjectInterface )
SEPARATE_ARGUMENTS ( CMAKE_SWIG_FLAGS )

CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/AssemblyInfo.cs.in
${CMAKE_CURRENT_BINARY_DIR}/AssemblyInfo.cs
@ONLY)

# libMyProjectInterface.so
#---
link_directories ( ${Boost_LIBRARY_DIRS} )
SWIG_ADD_MODULE(MyProjectInterface csharp SWIG_MyProject_Interface.i)
SWIG_LINK_LIBRARIES(MyProjectInterface MyProject ${Boost_LIBRARIES})

IF(UNIX)
  SET_TARGET_PROPERTIES(${SWIG_MODULE_MyProjectInterface_REAL_NAME} 
PROPERTIES PREFIX lib)
ENDIF(UNIX)
SET_TARGET_PROPERTIES(${SWIG_MODULE_MyProjectInterface_REAL_NAME} 
PROPERTIES LINK_INTERFACE_LIBRARIES )   

# Add custom command to build libMyProjectInterface.so
#---
ADD_CUSTOM_COMMAND(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/MyProject-csharp.dll
  COMMAND ${CMAKE_CSHARP_COMPILER} ARGS /t:library 
/out:${CMAKE_CURRENT_BINARY_DIR}/MyProject-csharp.dll *.cs
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  DEPENDS ${swig_generated_file_fullname} 
${CMAKE_CURRENT_BINARY_DIR}/AssemblyInfo.cs
  COMMENT csc *.cs)
  
ADD_CUSTOM_TARGET(MyProjectCSharp ALL
  DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/MyProject-csharp.dll