New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] New CMake build system. #17

Closed
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@jeandudey
Contributor

jeandudey commented May 18, 2015

Experimental CMake build system.

Solves #9 #10.

What do you think about it?

@davidrmiller

This comment has been minimized.

Show comment
Hide comment
@davidrmiller

davidrmiller May 18, 2015

Owner

Hi Jean, I'm looking forward to examining what you did in detail. However, give me a few days, as I'm currently scrambling to fix some serious problems in convolution networking.

Owner

davidrmiller commented May 18, 2015

Hi Jean, I'm looking forward to examining what you did in detail. However, give me a few days, as I'm currently scrambling to fix some serious problems in convolution networking.

@davidrmiller

This comment has been minimized.

Show comment
Hide comment
@davidrmiller

davidrmiller May 22, 2015

Owner

I like the directory hierarchy; that helps organize the files.

I'm not very familiar with either the Microsoft world or with CMake, so forgive me for asking some dumb questions:

  1. What problems does CMake solve for MSVC programmers?
  2. What problems does CMake solve for MSYS2/MSYS programmers?
  3. If I understand it correctly, this CMake solution does not solve the problem of compiling the webserver using MSVC, right? Would you still have to compile on Cygwin to use the neural2d GUI in Windows environment?
  4. If I understand it correctly, you can use a Makefile with MSVC, or import it, or convert it to a project, or something like that. Are there changes we could make to the neural2d Makefile to make it more easy to use in MSVC?
  5. Are there other alternatives for building neural2d on MSVC, such as including some sort of pre-made project file or something like that?
  6. Using CMake would introduce an additional dependency (on CMake itself). Do you think CMake would be available on all platforms where neural2d might be used? Will we still have a Makefile that will work on systems where CMake is not available?
Owner

davidrmiller commented May 22, 2015

I like the directory hierarchy; that helps organize the files.

I'm not very familiar with either the Microsoft world or with CMake, so forgive me for asking some dumb questions:

  1. What problems does CMake solve for MSVC programmers?
  2. What problems does CMake solve for MSYS2/MSYS programmers?
  3. If I understand it correctly, this CMake solution does not solve the problem of compiling the webserver using MSVC, right? Would you still have to compile on Cygwin to use the neural2d GUI in Windows environment?
  4. If I understand it correctly, you can use a Makefile with MSVC, or import it, or convert it to a project, or something like that. Are there changes we could make to the neural2d Makefile to make it more easy to use in MSVC?
  5. Are there other alternatives for building neural2d on MSVC, such as including some sort of pre-made project file or something like that?
  6. Using CMake would introduce an additional dependency (on CMake itself). Do you think CMake would be available on all platforms where neural2d might be used? Will we still have a Makefile that will work on systems where CMake is not available?
@jeandudey

This comment has been minimized.

Show comment
Hide comment
@jeandudey

jeandudey May 22, 2015

Contributor
  1. It can create solutions for different versions of Visual Studio and manage its dependencies directly from CMake.
  2. CMake can create custom a Makefile based on the system that is running, in this case: Windows.
    But not only for MSYS or MSYS2 it can also for Unix-based systems including Cygwin.
  3. Yes you are correctly, the Visual Studio or Makefile that CMake generates for windows cant compile the webserver because sys/sockets.h is part of the POSIX standard and windows isnt based on it and uses their own version of sys/sockets.h named winsock wich is a quite different from sys/sockets.h. This issue can be solved by the creation of two classes that inherits webserver, one class that handles the winsock library and the other that handle the POSIX sockets and in the Makefile/Solution generation time decide what class to use by creating a config.h file to handle the class that the library it will be using.
  4. Yes you can use a Makefile in Visual Studio but it will be only for it and not compatible with the standard make, instead CMake generates a Visual Studio solution as i explained in the first answer.
  5. Explained in the first answer.
  6. Yes it will introduce an additional dependency, because CMake creates a Makefile that calls CMake.
Contributor

jeandudey commented May 22, 2015

  1. It can create solutions for different versions of Visual Studio and manage its dependencies directly from CMake.
  2. CMake can create custom a Makefile based on the system that is running, in this case: Windows.
    But not only for MSYS or MSYS2 it can also for Unix-based systems including Cygwin.
  3. Yes you are correctly, the Visual Studio or Makefile that CMake generates for windows cant compile the webserver because sys/sockets.h is part of the POSIX standard and windows isnt based on it and uses their own version of sys/sockets.h named winsock wich is a quite different from sys/sockets.h. This issue can be solved by the creation of two classes that inherits webserver, one class that handles the winsock library and the other that handle the POSIX sockets and in the Makefile/Solution generation time decide what class to use by creating a config.h file to handle the class that the library it will be using.
  4. Yes you can use a Makefile in Visual Studio but it will be only for it and not compatible with the standard make, instead CMake generates a Visual Studio solution as i explained in the first answer.
  5. Explained in the first answer.
  6. Yes it will introduce an additional dependency, because CMake creates a Makefile that calls CMake.
@davidrmiller

This comment has been minimized.

Show comment
Hide comment
@davidrmiller

davidrmiller May 23, 2015

Owner

Thanks, that helps. I like the concept. I'll experiment some more with the work you did and learn more about it.

Owner

davidrmiller commented May 23, 2015

Thanks, that helps. I like the concept. I'll experiment some more with the work you did and learn more about it.

davidrmiller added a commit that referenced this pull request May 27, 2015

@davidrmiller

This comment has been minimized.

Show comment
Hide comment
@davidrmiller

davidrmiller May 27, 2015

Owner

@jeandudey, using your work as inspiration, I tried making my own branch using CMake. I would love to get your feedback on it.

I tested it by building and running unitTest and neural2d on the digits demo on Linux with GNU and Clang, and on Cygwin (GNU), and in Windows using the Visual Studio 2013 Community Edition.

If I did anything silly, let me know. I'm still a CMake noob.

Details:

  1. The images in the images/ directory are shared resources used for multiple purposes, so I left that directory at the top level. To make it easy to run the digits test, I tried to make a rule to automatically unpack the images/digits.zip archive when needed using CMake's tar function, which happily unpacks .zip archives as well.
  2. To minimize the CMake plumbing, I used only one CMakeLists.txt at the top level that does everything.
  3. To simplify the build process, I tweaked the webserver code so that the unitTest executable can be linked with the webserver stuff. Now the build process will build the core library in two forms -- with and without the webserver. Then you can link to either one. If WEBSERVER=OFF, only the library without the webserver gets built.

The README.md file has been revised with new build instructions as shown below. If there are any errors or if I can explain anything more clearly, let me know.

Compiling the source

We use CMake to configure the build system. First get the source code from the Gitub repository. If using the command line, the command is:

 git clone https://github.com/davidrmiller/neural2d

That will put the source code tree into a directory named neural2d.

If you are using the CMake graphical interface, run it and set the "source" directory to the neural2d top directory, and set the binary output directory to a build directory under that, then click Configure and Generate. For example:

CMake GUI example

If you are using CMake from the command line, cd to the neural2d top level directory, make a build directory, then run cmake from there:

git clone https://github.com/davidrmiller/neural2d
cd neural2d
mkdir build
cd build
cmake ..
make

There is no "install" step. After the neural2d program is compiled, you can execute it or open the project file from the build directory.

On Windows, by default CMake generates a Microsoft Visual Studio project file in the build directory. On Linux and Cygwin, CMake generates a Makefile that you can use to compile neural2d. You can specify a different CMake generator with the -G option, for example:

 cmake -G "Visual Studio 11 2012" ..

To get a list of available CMake generators:

 cmake --help

If you get errors when compiling the integrated webserver, you can build neural2d without webserver support by running CMake with the -DWEBSERVER=OFF option, like this:

 cmake -DWEBSERVER=OFF ..
Owner

davidrmiller commented May 27, 2015

@jeandudey, using your work as inspiration, I tried making my own branch using CMake. I would love to get your feedback on it.

I tested it by building and running unitTest and neural2d on the digits demo on Linux with GNU and Clang, and on Cygwin (GNU), and in Windows using the Visual Studio 2013 Community Edition.

If I did anything silly, let me know. I'm still a CMake noob.

Details:

  1. The images in the images/ directory are shared resources used for multiple purposes, so I left that directory at the top level. To make it easy to run the digits test, I tried to make a rule to automatically unpack the images/digits.zip archive when needed using CMake's tar function, which happily unpacks .zip archives as well.
  2. To minimize the CMake plumbing, I used only one CMakeLists.txt at the top level that does everything.
  3. To simplify the build process, I tweaked the webserver code so that the unitTest executable can be linked with the webserver stuff. Now the build process will build the core library in two forms -- with and without the webserver. Then you can link to either one. If WEBSERVER=OFF, only the library without the webserver gets built.

The README.md file has been revised with new build instructions as shown below. If there are any errors or if I can explain anything more clearly, let me know.

Compiling the source

We use CMake to configure the build system. First get the source code from the Gitub repository. If using the command line, the command is:

 git clone https://github.com/davidrmiller/neural2d

That will put the source code tree into a directory named neural2d.

If you are using the CMake graphical interface, run it and set the "source" directory to the neural2d top directory, and set the binary output directory to a build directory under that, then click Configure and Generate. For example:

CMake GUI example

If you are using CMake from the command line, cd to the neural2d top level directory, make a build directory, then run cmake from there:

git clone https://github.com/davidrmiller/neural2d
cd neural2d
mkdir build
cd build
cmake ..
make

There is no "install" step. After the neural2d program is compiled, you can execute it or open the project file from the build directory.

On Windows, by default CMake generates a Microsoft Visual Studio project file in the build directory. On Linux and Cygwin, CMake generates a Makefile that you can use to compile neural2d. You can specify a different CMake generator with the -G option, for example:

 cmake -G "Visual Studio 11 2012" ..

To get a list of available CMake generators:

 cmake --help

If you get errors when compiling the integrated webserver, you can build neural2d without webserver support by running CMake with the -DWEBSERVER=OFF option, like this:

 cmake -DWEBSERVER=OFF ..
@jeandudey

This comment has been minimized.

Show comment
Hide comment
@jeandudey

jeandudey May 27, 2015

Contributor

Wow! you re good to be new to CMake;, the work you did with CMake is good and runs good, i tested it on Cygwin, MSYS, MSYS2, Visual Studio and everything works well!

About the README.md:
Everything is good but you can use the install command to have a "make install" like command for the project.

Contributor

jeandudey commented May 27, 2015

Wow! you re good to be new to CMake;, the work you did with CMake is good and runs good, i tested it on Cygwin, MSYS, MSYS2, Visual Studio and everything works well!

About the README.md:
Everything is good but you can use the install command to have a "make install" like command for the project.

@davidrmiller

This comment has been minimized.

Show comment
Hide comment
@davidrmiller

davidrmiller May 28, 2015

Owner

@jeandudey, thanks so much for the kind feedback, and for doing all that testing, and for doing the initial CMake conversion. You have helped make neural2d a better program.

Owner

davidrmiller commented May 28, 2015

@jeandudey, thanks so much for the kind feedback, and for doing all that testing, and for doing the initial CMake conversion. You have helped make neural2d a better program.

@jeandudey

This comment has been minimized.

Show comment
Hide comment
@jeandudey

jeandudey May 28, 2015

Contributor

👍

Contributor

jeandudey commented May 28, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment