Problem building Kitchensink with VS2022

Peter H
Posts: 7
Joined: Wed May 24 2023 7:26 am

Problem building Kitchensink with VS2022

Post by Peter H »

Hello,
I am not experienced with CMake.
I followed the instructions, which I found online, downloaded Copperspice and Kitchensink sources from Git, using Visual Studio 22 and built Copperspice successfully.

When I try to build Kitchensink, I get this error:

Code: Select all

CMake Error at CMakeLists.txt:29 (find_package):
  Could not find a configuration file for package "CopperSpice" that is
  compatible with requested version "".

  The following configuration files were considered but not accepted:

    C:/CSP/cmake/CopperSpiceConfig.cmake, version: @BUILD_MAJOR@.@BUILD_MINOR@.@BUILD_MICRO@

Der Thread 'CMake script' (0x1) hat mit Code 0 (0x0) geendet.
Das Programm "cmd.exe" wurde mit Code 1 (0x1) beendet.
I tried to fix it, but no success, and I am not experienced and do not know if VC2022 is fully compatible.
I have some ten years ago programmed in C and Assembler and even wrote makefiles, but have no knowledge about CMake so far.
Any hint or help would be welcome.

Thank you in advance,

Peter
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Problem building Kitchensink with VS2022

Post by barbara »

Peter,

1) Although you mentioned using Visual Studio 2022, you are probably using the MSVC compiler with the Visual Studio IDE. This is supported however our CI server uses Visual Studio 2019. The binary files we released for MSVC are fully tested.

For the complete list of our supported platforms you can refer to the following page in our CS Overview Documentation.

https://www.copperspice.com/docs/cs_overview/supported-platforms.html

2) After you built the CopperSpice libraries did you install? Please take a look at the following page in our documentation. Towards the bottom of the page we show how to set up the install path.

https://www.copperspice.com/docs/cs_overview/build-msvc.html

3) Then you will need to build and install KitchenSink. Please have a look at the following page in our documentation.

https://www.copperspice.com/docs/cs_overview/demo-ks.html

4) For another reference we have a Journal ( basically a blog ) with lots working examples. Example 1 provides information about how to build and deploy on every supported platform.

https://journal.copperspice.com/

Please let us know if you have other questions.

Barbara
Peter H
Posts: 7
Joined: Wed May 24 2023 7:26 am

Re: Problem building Kitchensink with VS2022

Post by Peter H »

Thank you very much for your answer.
Yes this Journal Article leads me to the overview site and I followed the instructions there.

I followed the Instructions here: https://www.copperspice.com/docs/cs_overview/build-msvc.html
Yes I used the IDE and not the VS Command prompt. This of course in turn uses the VC compiler.

I built and installed Copperspice from Github sources and this was successfull.

The instructions say this, and I did this:
Highlight the CMake menu (located on the menu bar) then select the "Change CMake Settings" option
Click on "copperspice"
In the editor window add or change the path for CMAKE_INSTALL_PREFIX to YOUR_INSTALL_PATH
"cmakeCommandArgs": "-DCMAKE_INSTALL_PREFIX=YOUR_INSTALL_PATH"
Set an environment variable called CMAKE_PREFIX_PATH to YOUR_INSTALL_PATH


I have set "YOUR_INSTALL_PATH" to C:\CSP where the cmakelists.txt is, is this correct?

Now, when I try to build Kitchensink, then it says: could not find a configuration file with version "". (see my previous post)
Why is the version empty?
Shouldnt it be Major,Minor,Micro, which is 1.8.2. ?
It says:

Code: Select all

 The following configuration files were considered but not accepted:

    C:/CSP/cmake/CopperSpiceConfig.cmake, version: @BUILD_MAJOR@.@BUILD_MINOR@.@BUILD_MICRO@

It found obviously the correct configuration file but does not accept it, why?
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Problem building Kitchensink with VS2022

Post by barbara »

I have set "YOUR_INSTALL_PATH" to C:\CSP where the cmakelists.txt is, is this correct?
I would like to back up and add a bit of CMake information. CopperSpice is built out-of-tree, which is a very common practice. This is the only way VS will actually build a CMake project.

There are three different directories: cs_source, cs_build, and cs_lib. The full source code is located in cs_source and nothing else will be present. The build process takes place in cs_build. Once the project is built the necessary files will be copied to cs_lib. The CMAKE_INSTALL_PREFIX variable needs to be specified when building CopperSpice and it must be assigned to the install location. Using our values this will be cs_lib.

After looking at your question we have updated the CS Overview documentation to clarify the path locations.

https://www.copperspice.com/docs/cs_overview/build-msvc.html

Our guess is that you assigned the installed path to the location of your source. This would explain why the version is not showing up. Once the files are installed the "CopperSpiceConfigVersion.cmake" file in cs_lib/cmake will say 1.8.2. You may need to clean the source folder since installing here may have corrupted some files.

Barbara
Peter H
Posts: 7
Joined: Wed May 24 2023 7:26 am

Re: Problem building Kitchensink with VS2022

Post by Peter H »

Thank you!
I will try this and report.

In the meantime I tried Installing and building Copperspice and Kitchensink over VS commandline, as described here: https://www.copperspice.com/docs/cs_overview/sample-ks-msvc.html.

This worked without problem. However it needs admin privilege, because it installs DLLs and include files in Program Files (x86)
(I am on Windows 11 64 bit)
This is not exactly what I wanted, so I will try what you described.

One Question added: Must I set Environment variables and to which location, when my Copperspice directory is C:\CSP ?
Peter H
Posts: 7
Joined: Wed May 24 2023 7:26 am

[solved] Re: Problem building Kitchensink with VS2022

Post by Peter H »

I deleted the old directory and repeated the process from beginning.
I did not make any directories.

I cloned the Copperspice Github repository to C:\CSP, using VS2022.

Then I opened this directory in VS 2022. It automatically recognizes CMakelists.txt and starts to unpack files and creates a directory structure.
(I do not know, if this can be stopped or somehow configured, it happens automatically, when I open the C:\CSP directory)

I attach an image of the structure, which VS2022 has automatically created:
Image

Edit:
It compiles now without errors.
I set the environment variable CMAKE_INSTALL_PREFIX to "C:\CSP\out\build\x64-Debug\lib".
Then I built and installed Copperspice.
When starting Kitchensink in the debugger, it does not find its DLLS.

This is another problem. I hope, I can solve this myself.

Thank you very much for helping!
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Problem building Kitchensink with VS2022

Post by barbara »

I set the environment variable CMAKE_INSTALL_PREFIX to "C:\CSP\out\build\x64-Debug\lib".
There are two problems here. (1) You should not be specifying a folder inside of your source directory. You need to tell CMake where to install, which should be a clean folder. (2) This variable should not be set in your environment since different projects should not be installed to the same directory.

The correct way is to use the MSVC editor to add the following line to your CMake settings file. The value for "/c/csp_lib" could be anything but it should not point to a location in the source folder.

"cmakeCommandArgs": "-DCMAKE_INSTALL_PREFIX=c:\\csp_lib".
When starting Kitchensink in the debugger, it does not find its DLLS.
The CMake configure for KS is slightly different since you need to tell this project where the CMake files for CS are located. This is the variable which can be set in the environment so every project can find CopperSpice. Notice the name is different.

CMAKE_PREFIX_PATH="c:\\csp_lib\\cmake\\CopperSpice". [ Minor Edit, forgot to double the backslash ]


Barbara
Peter H
Posts: 7
Joined: Wed May 24 2023 7:26 am

Re: Problem building Kitchensink with VS2022

Post by Peter H »

Yes thank you.
As said. I did not create this directory structure. VS2022 created it fully automatically without any questions asked.
I cloned the repo as instructed and did exactly as instructed and this structure was automatically built.
"Exactly" means: I cloned the repo, in VS Studio I choose "Open" and "CMake..." and when you do so, it it will automagically and immediately create this structure.

Initially I believed this is predefined this way and intended.
Now after I repeated the installation process, I watched VS Studio creating this directory structure.

If this is not a good way, then VS Studio cannot be used with CMake and Copperspice.

If you follow the instructions, this is the result.
When I do as instructed, then this structure is created automatically and I do not know how to change this.
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Problem building Kitchensink with VS2022

Post by barbara »

Please understand that MSVC and VS are a fully supported platform and has been for over 7 years. We have a lot of users on this platform and we can assure you it works.

There is no issue with how MSVC sets up the project and then builds. It will "build" in the folder as you showed in your tree structure. There are other ways they could have done this process but it has no barring on the "install" process. Other platforms do build in a separate folder but again, this is fine. There is nothing wrong with your build process.

The entire problem you are experiencing is how you have told MSVC to "install" CopperSpice. Microsoft provides full support for CMake however there are settings you must make so CMake and Ninja know what to do. Keep in mind that some users have CMake experience but we absolutely understand other users do not. We are going to help you.

If you follow these directions it will work. To ensure this we just verified it again on our CI server.

1 Remove the environment variable of CMAKE_INSTALL_PREFIX ( if you have not already )

2 Here are more detailed directions to add the install path for CopperSpice. In VS highlight the project menu and select "CMake Settings for CopperSpice". Change the path for ""cmakeCommandArgs" to the following. The path can be changed, but I would strongly suggest you first test with the path listed here.

Code: Select all

"cmakeCommandArgs": "-DCMAKE_INSTALL_PREFIX=c:\\csp_lib"
Once you do this then CopperSpice will build and install. Now you will see a new folder on the C drive called "csp_lib". This folder will contain all of the files KS needs to build. If you want to verify your build, simply download our pre-built MSVC binary files to compare.

Let us know your progress and then we can focus on any issues you are having with KS.

Barbara
Peter H
Posts: 7
Joined: Wed May 24 2023 7:26 am

Re: Problem building Kitchensink with VS2022

Post by Peter H »

barbara wrote: Fri May 26 2023 5:44 pm The entire problem you are experiencing is how you have told MSVC to "install" CopperSpice. Microsoft provides full support for CMake however there are settings you must make so CMake and Ninja know what to do. Keep in mind that some users have CMake experience but we absolutely understand other users do not. We are going to help you.

If you follow these directions it will work. To ensure this we just verified it again on our CI server.

1 Remove the environment variable of CMAKE_INSTALL_PREFIX ( if you have not already )

2 Here are more detailed directions to add the install path for CopperSpice. In VS highlight the project menu and select "CMake Settings for CopperSpice". Change the path for ""cmakeCommandArgs" to the following. The path can be changed, but I would strongly suggest you first test with the path listed here.

Code: Select all

"cmakeCommandArgs": "-DCMAKE_INSTALL_PREFIX=c:\\csp_lib"
Thank you very much!

The problem is: When I have cloned the repository but did not open the Copperspice directory, then I cannot find the "CMake Settings for CopperSpice" item in the VS project menu.
When I open the directory and choose "CMake Settings" then VS after some seconds finds the CMakeLists.txt file and creates the aforementioned directory structure without Questions asked.

I have read the Microsoft documentation about CMake and VS. When there is a CMakeLists.txt file in the root of the project, VS2022 will automatically open it and execute it.(Before I can change any settings) This is what Microsoft documentation says and this happened.
Before this happens, I have no project where I can change settings.

After I did so, it looks like this:
Image
Everything was created automatically without Questions asked.
So probably, I must change the CMakeLists.txt or the JSON file before I open it with Visual Studio?
Or should I configure the CMake project with the CMake GUI (which I have installed, but never used) before I create a project in Visual Studio?
(Open the image in new Tab, to see it in 100% Size)

Only after this happened, project settings can be changed or added.
If I change CMAKE_INSTALL_PREFIX in this screen to c:\\csp_lib it gives an error and says "double defined".
I again deleted everything and cloned the Github again and tried it some seconds ago and just this happened.

Question: My final goal (I am not a professional) is to make smaller projects, which have a rather simple GUI (Menu, Editfields, Images etc) and are statically linked. (no DLLs) Is this possible?
Post Reply